-
Notifications
You must be signed in to change notification settings - Fork 13.1k
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
suggest using a appropriate keyword for
struct
and enum
- Loading branch information
Showing
3 changed files
with
134 additions
and
21 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
13 changes: 13 additions & 0 deletions
13
src/test/ui/suggestions/suggest-using-appropriate-keyword-for-struct-and-enum.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 |
---|---|---|
@@ -0,0 +1,13 @@ | ||
pub struct NotStruct { | ||
Variant | ||
} //~ ERROR expected `:`, found `}` | ||
|
||
pub struct NotStruct { | ||
field String //~ ERROR expected `:`, found `String` | ||
} | ||
|
||
pub enum NotEnum { | ||
field: u8 //~ ERROR the enum cannot have a struct field declaration | ||
} | ||
|
||
fn main() {} |
32 changes: 32 additions & 0 deletions
32
src/test/ui/suggestions/suggest-using-appropriate-keyword-for-struct-and-enum.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 |
---|---|---|
@@ -0,0 +1,32 @@ | ||
error: expected `:`, found `}` | ||
--> $DIR/suggest-using-appropriate-keyword-for-struct-and-enum.rs:3:1 | ||
| | ||
LL | Variant | ||
| - expected `:` | ||
LL | } | ||
| ^ unexpected token | ||
| | ||
help: consider using `enum` instead of `struct` | ||
| | ||
LL | pub enum NotStruct { | ||
| ~~~~ | ||
|
||
error: expected `:`, found `String` | ||
--> $DIR/suggest-using-appropriate-keyword-for-struct-and-enum.rs:6:11 | ||
| | ||
LL | field String | ||
| ^^^^^^ expected `:` | ||
|
||
error: the enum cannot have a struct field declaration | ||
--> $DIR/suggest-using-appropriate-keyword-for-struct-and-enum.rs:10:5 | ||
| | ||
LL | field: u8 | ||
| ^^^^^^^^^ | ||
| | ||
help: consider using `struct` instead of `enum` | ||
| | ||
LL | pub struct NotEnum { | ||
| ~~~~~~ | ||
|
||
error: aborting due to 3 previous errors | ||
|