mirror of
https://github.com/rust-lang/rust-analyzer.git
synced 2025-12-09 10:55:42 +00:00
Fix rustfmt for files that use 2024-edition syntax
"cargo fmt" works fine but "rustfmt" fails to format some files. $ rustfmt crates/ide-db/src/search.rs error: let chains are only allowed in Rust 2024 or later --> /home/johannes/git/rust-analyzer/crates/ide-db/src/search.rs:298:12 | 298 | if let &Definition::Module(module) = self | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ I guess I could work around this by setting my format command to "cargo fmt -- $filename" instead of "rustfmt $filename". But it'd be nice if this worked OOTB. Make it so by adding specifying the edition in rustfmt.toml. We already have several other places specifying the edition. changelog internal
This commit is contained in:
parent
d2559a7c40
commit
70f972c2fd
3 changed files with 167 additions and 822 deletions
File diff suppressed because it is too large
Load diff
|
|
@ -1,9 +1,9 @@
|
|||
//! Generated by `cargo xtask codegen grammar`, do not edit by hand.
|
||||
|
||||
use crate::{
|
||||
ast::AstToken,
|
||||
SyntaxKind::{self, *},
|
||||
SyntaxToken,
|
||||
ast::AstToken,
|
||||
};
|
||||
use std::{fmt, hash};
|
||||
pub struct Byte {
|
||||
|
|
@ -17,11 +17,7 @@ impl std::fmt::Display for Byte {
|
|||
impl AstToken for Byte {
|
||||
fn can_cast(kind: SyntaxKind) -> bool { kind == BYTE }
|
||||
fn cast(syntax: SyntaxToken) -> Option<Self> {
|
||||
if Self::can_cast(syntax.kind()) {
|
||||
Some(Self { syntax })
|
||||
} else {
|
||||
None
|
||||
}
|
||||
if Self::can_cast(syntax.kind()) { Some(Self { syntax }) } else { None }
|
||||
}
|
||||
fn syntax(&self) -> &SyntaxToken { &self.syntax }
|
||||
}
|
||||
|
|
@ -51,11 +47,7 @@ impl std::fmt::Display for ByteString {
|
|||
impl AstToken for ByteString {
|
||||
fn can_cast(kind: SyntaxKind) -> bool { kind == BYTE_STRING }
|
||||
fn cast(syntax: SyntaxToken) -> Option<Self> {
|
||||
if Self::can_cast(syntax.kind()) {
|
||||
Some(Self { syntax })
|
||||
} else {
|
||||
None
|
||||
}
|
||||
if Self::can_cast(syntax.kind()) { Some(Self { syntax }) } else { None }
|
||||
}
|
||||
fn syntax(&self) -> &SyntaxToken { &self.syntax }
|
||||
}
|
||||
|
|
@ -85,11 +77,7 @@ impl std::fmt::Display for CString {
|
|||
impl AstToken for CString {
|
||||
fn can_cast(kind: SyntaxKind) -> bool { kind == C_STRING }
|
||||
fn cast(syntax: SyntaxToken) -> Option<Self> {
|
||||
if Self::can_cast(syntax.kind()) {
|
||||
Some(Self { syntax })
|
||||
} else {
|
||||
None
|
||||
}
|
||||
if Self::can_cast(syntax.kind()) { Some(Self { syntax }) } else { None }
|
||||
}
|
||||
fn syntax(&self) -> &SyntaxToken { &self.syntax }
|
||||
}
|
||||
|
|
@ -119,11 +107,7 @@ impl std::fmt::Display for Char {
|
|||
impl AstToken for Char {
|
||||
fn can_cast(kind: SyntaxKind) -> bool { kind == CHAR }
|
||||
fn cast(syntax: SyntaxToken) -> Option<Self> {
|
||||
if Self::can_cast(syntax.kind()) {
|
||||
Some(Self { syntax })
|
||||
} else {
|
||||
None
|
||||
}
|
||||
if Self::can_cast(syntax.kind()) { Some(Self { syntax }) } else { None }
|
||||
}
|
||||
fn syntax(&self) -> &SyntaxToken { &self.syntax }
|
||||
}
|
||||
|
|
@ -153,11 +137,7 @@ impl std::fmt::Display for Comment {
|
|||
impl AstToken for Comment {
|
||||
fn can_cast(kind: SyntaxKind) -> bool { kind == COMMENT }
|
||||
fn cast(syntax: SyntaxToken) -> Option<Self> {
|
||||
if Self::can_cast(syntax.kind()) {
|
||||
Some(Self { syntax })
|
||||
} else {
|
||||
None
|
||||
}
|
||||
if Self::can_cast(syntax.kind()) { Some(Self { syntax }) } else { None }
|
||||
}
|
||||
fn syntax(&self) -> &SyntaxToken { &self.syntax }
|
||||
}
|
||||
|
|
@ -187,11 +167,7 @@ impl std::fmt::Display for FloatNumber {
|
|||
impl AstToken for FloatNumber {
|
||||
fn can_cast(kind: SyntaxKind) -> bool { kind == FLOAT_NUMBER }
|
||||
fn cast(syntax: SyntaxToken) -> Option<Self> {
|
||||
if Self::can_cast(syntax.kind()) {
|
||||
Some(Self { syntax })
|
||||
} else {
|
||||
None
|
||||
}
|
||||
if Self::can_cast(syntax.kind()) { Some(Self { syntax }) } else { None }
|
||||
}
|
||||
fn syntax(&self) -> &SyntaxToken { &self.syntax }
|
||||
}
|
||||
|
|
@ -221,11 +197,7 @@ impl std::fmt::Display for Ident {
|
|||
impl AstToken for Ident {
|
||||
fn can_cast(kind: SyntaxKind) -> bool { kind == IDENT }
|
||||
fn cast(syntax: SyntaxToken) -> Option<Self> {
|
||||
if Self::can_cast(syntax.kind()) {
|
||||
Some(Self { syntax })
|
||||
} else {
|
||||
None
|
||||
}
|
||||
if Self::can_cast(syntax.kind()) { Some(Self { syntax }) } else { None }
|
||||
}
|
||||
fn syntax(&self) -> &SyntaxToken { &self.syntax }
|
||||
}
|
||||
|
|
@ -255,11 +227,7 @@ impl std::fmt::Display for IntNumber {
|
|||
impl AstToken for IntNumber {
|
||||
fn can_cast(kind: SyntaxKind) -> bool { kind == INT_NUMBER }
|
||||
fn cast(syntax: SyntaxToken) -> Option<Self> {
|
||||
if Self::can_cast(syntax.kind()) {
|
||||
Some(Self { syntax })
|
||||
} else {
|
||||
None
|
||||
}
|
||||
if Self::can_cast(syntax.kind()) { Some(Self { syntax }) } else { None }
|
||||
}
|
||||
fn syntax(&self) -> &SyntaxToken { &self.syntax }
|
||||
}
|
||||
|
|
@ -289,11 +257,7 @@ impl std::fmt::Display for String {
|
|||
impl AstToken for String {
|
||||
fn can_cast(kind: SyntaxKind) -> bool { kind == STRING }
|
||||
fn cast(syntax: SyntaxToken) -> Option<Self> {
|
||||
if Self::can_cast(syntax.kind()) {
|
||||
Some(Self { syntax })
|
||||
} else {
|
||||
None
|
||||
}
|
||||
if Self::can_cast(syntax.kind()) { Some(Self { syntax }) } else { None }
|
||||
}
|
||||
fn syntax(&self) -> &SyntaxToken { &self.syntax }
|
||||
}
|
||||
|
|
@ -323,11 +287,7 @@ impl std::fmt::Display for Whitespace {
|
|||
impl AstToken for Whitespace {
|
||||
fn can_cast(kind: SyntaxKind) -> bool { kind == WHITESPACE }
|
||||
fn cast(syntax: SyntaxToken) -> Option<Self> {
|
||||
if Self::can_cast(syntax.kind()) {
|
||||
Some(Self { syntax })
|
||||
} else {
|
||||
None
|
||||
}
|
||||
if Self::can_cast(syntax.kind()) { Some(Self { syntax }) } else { None }
|
||||
}
|
||||
fn syntax(&self) -> &SyntaxToken { &self.syntax }
|
||||
}
|
||||
|
|
|
|||
|
|
@ -1,2 +1,3 @@
|
|||
edition = "2024"
|
||||
reorder_modules = true
|
||||
use_small_heuristics = "Max"
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue