-
Notifications
You must be signed in to change notification settings - Fork 12.7k
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Fix let removal suggestion in struct
- Loading branch information
1 parent
cde693c
commit f9d3c83
Showing
6 changed files
with
81 additions
and
12 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,6 @@ | ||
struct Foo { | ||
let: i32, | ||
//~^ ERROR expected identifier, found keyword | ||
} | ||
|
||
fn main() {} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,15 @@ | ||
error: expected identifier, found keyword `let` | ||
--> $DIR/bad-let-as-field.rs:2:5 | ||
| | ||
LL | struct Foo { | ||
| --- while parsing this struct | ||
LL | let: i32, | ||
| ^^^ expected identifier, found keyword | ||
| | ||
help: escape `let` to use it as an identifier | ||
| | ||
LL | r#let: i32, | ||
| ++ | ||
|
||
error: aborting due to previous error | ||
|
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,12 @@ | ||
struct Foo { | ||
let x: i32, | ||
//~^ ERROR expected identifier, found keyword | ||
let y: i32, | ||
//~^ ERROR expected identifier, found keyword | ||
} | ||
|
||
fn main() { | ||
let _ = Foo { | ||
//~^ ERROR missing fields `x` and `y` in initializer of `Foo` | ||
}; | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,33 @@ | ||
error: expected identifier, found keyword `let` | ||
--> $DIR/removed-syntax-field-let-2.rs:2:5 | ||
| | ||
LL | let x: i32, | ||
| ^^^- | ||
| | | ||
| expected identifier, found keyword | ||
| help: remove this `let` keyword | ||
| | ||
= note: the `let` keyword is not allowed in `struct` fields | ||
= note: see <https://doc.rust-lang.org/book/ch05-01-defining-structs.html> for more information | ||
|
||
error: expected identifier, found keyword `let` | ||
--> $DIR/removed-syntax-field-let-2.rs:4:5 | ||
| | ||
LL | let y: i32, | ||
| ^^^- | ||
| | | ||
| expected identifier, found keyword | ||
| help: remove this `let` keyword | ||
| | ||
= note: the `let` keyword is not allowed in `struct` fields | ||
= note: see <https://doc.rust-lang.org/book/ch05-01-defining-structs.html> for more information | ||
|
||
error[E0063]: missing fields `x` and `y` in initializer of `Foo` | ||
--> $DIR/removed-syntax-field-let-2.rs:9:13 | ||
| | ||
LL | let _ = Foo { | ||
| ^^^ missing `x` and `y` | ||
|
||
error: aborting due to 3 previous errors | ||
|
||
For more information about this error, try `rustc --explain E0063`. |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters