File tree Expand file tree Collapse file tree 1 file changed +19
-0
lines changed
compiler/rustc_parse/src/parser Expand file tree Collapse file tree 1 file changed +19
-0
lines changed Original file line number Diff line number Diff line change @@ -1216,6 +1216,25 @@ impl<'a> Parser<'a> {
12161216
12171217 /// Parses an enum declaration.
12181218 fn parse_item_enum ( & mut self ) -> PResult < ' a , ItemInfo > {
1219+ if self . token . is_keyword ( kw:: Struct ) {
1220+ let mut err = self . struct_span_err (
1221+ self . prev_token . span . to ( self . token . span ) ,
1222+ "`enum` and `struct` are mutually exclusive" ,
1223+ ) ;
1224+ err. span_suggestion (
1225+ self . prev_token . span . to ( self . token . span ) ,
1226+ "replace `enum struct` with" ,
1227+ "enum" ,
1228+ Applicability :: MachineApplicable ,
1229+ ) ;
1230+ if self . look_ahead ( 1 , |t| t. is_ident ( ) ) {
1231+ self . bump ( ) ;
1232+ err. emit ( ) ;
1233+ } else {
1234+ return Err ( err) ;
1235+ }
1236+ }
1237+
12191238 let id = self . parse_ident ( ) ?;
12201239 let mut generics = self . parse_generics ( ) ?;
12211240 generics. where_clause = self . parse_where_clause ( ) ?;
You can’t perform that action at this time.
0 commit comments