-
Notifications
You must be signed in to change notification settings - Fork 13k
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
suggest struct when we get colon in fileds in enum
- Loading branch information
1 parent
04c5344
commit 6b76588
Showing
4 changed files
with
37 additions
and
5 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,13 @@ | ||
// run-rustfix | ||
|
||
struct VecOrMap { | ||
//~^ HELP: perhaps you meant to use `struct` here | ||
vec: Vec<usize>, | ||
//~^ ERROR expected one of `(`, `,`, `=`, `{`, or `}`, found `:` | ||
//~| HELP: enum variants can be `Variant`, `Variant = <integer>`, `Variant(Type, ..., TypeN)` or `Variant { fields: Types }` | ||
} | ||
|
||
fn main() { | ||
let o = VecOrMap { vec: vec![1, 2, 3] }; | ||
println!("{:?}", o.vec); | ||
} |
11 changes: 8 additions & 3 deletions
11
tests/ui/parser/issue-103869.rs → tests/ui/structs-enums/issue-103869.rs
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 |
---|---|---|
@@ -1,8 +1,13 @@ | ||
enum VecOrMap{ | ||
// run-rustfix | ||
|
||
enum VecOrMap { | ||
//~^ HELP: perhaps you meant to use `struct` here | ||
vec: Vec<usize>, | ||
//~^ ERROR expected one of `(`, `,`, `=`, `{`, or `}`, found `:` | ||
//~| HELP: enum variants can be `Variant`, `Variant = <integer>`, `Variant(Type, ..., TypeN)` or `Variant { fields: Types }` | ||
map: HashMap<String,usize> | ||
} | ||
|
||
fn main() {} | ||
fn main() { | ||
let o = VecOrMap { vec: vec![1, 2, 3] }; | ||
println!("{:?}", o.vec); | ||
} |
9 changes: 7 additions & 2 deletions
9
tests/ui/parser/issue-103869.stderr → tests/ui/structs-enums/issue-103869.stderr
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 |
---|---|---|
@@ -1,12 +1,17 @@ | ||
error: expected one of `(`, `,`, `=`, `{`, or `}`, found `:` | ||
--> $DIR/issue-103869.rs:2:8 | ||
--> $DIR/issue-103869.rs:5:8 | ||
| | ||
LL | enum VecOrMap{ | ||
LL | enum VecOrMap { | ||
| -------- while parsing this enum | ||
LL | | ||
LL | vec: Vec<usize>, | ||
| ^ expected one of `(`, `,`, `=`, `{`, or `}` | ||
| | ||
= help: enum variants can be `Variant`, `Variant = <integer>`, `Variant(Type, ..., TypeN)` or `Variant { fields: Types }` | ||
help: perhaps you meant to use `struct` here | ||
| | ||
LL | struct VecOrMap { | ||
| ~~~~~~ | ||
|
||
error: aborting due to previous error | ||
|