@@ -4,9 +4,9 @@ use crate::errors::{
44 DefaultNotFollowedByItem , DocCommentDoesNotDocumentAnything , EnumStructMutuallyExclusive ,
55 ExpectedTraitInTraitImplFoundType , ExternCrateNameWithDashes , ExternCrateNameWithDashesSugg ,
66 ExternItemCannotBeConst , MissingConstType , MissingForInTraitImpl ,
7- MissingKeywordForItemDefinition , MissingTraitInTraitImpl , NonItemInItemList ,
8- NonItemInItemListSub , SelfArgumentPointer , TraitAliasCannotBeAuto , TraitAliasCannotBeUnsafe ,
9- UnexpectedTokenAfterStructName , UseEmptyBlockNotSemi , VisibilityNotFollowedByItem ,
7+ MissingKeywordForItemDefinition , MissingTraitInTraitImpl , SelfArgumentPointer ,
8+ TraitAliasCannotBeAuto , TraitAliasCannotBeUnsafe , UnexpectedTokenAfterStructName ,
9+ UseEmptyBlockNotSemi , VisibilityNotFollowedByItem ,
1010} ;
1111
1212use super :: diagnostics:: { dummy_arg, ConsumeClosingDelim } ;
@@ -703,22 +703,29 @@ impl<'a> Parser<'a> {
703703 let non_item_span = self . token . span ;
704704 let is_let = self . token . is_keyword ( kw:: Let ) ;
705705
706+ let mut err = self . struct_span_err ( non_item_span, "non-item in item list" ) ;
706707 self . consume_block ( Delimiter :: Brace , ConsumeClosingDelim :: Yes ) ;
707-
708- self . sess . emit_err ( NonItemInItemList {
709- span : non_item_span,
710- sub : if is_let {
711- NonItemInItemListSub :: Let { span : non_item_span }
712- } else {
713- NonItemInItemListSub :: Other {
714- list_start : open_brace_span,
715- non_item : non_item_span,
716- list_end : self . prev_token . span ,
717- }
718- } ,
719- remove_semicolon : is_unnecessary_semicolon. then_some ( semicolon_span) ,
720- } ) ;
721-
708+ if is_let {
709+ err. span_suggestion (
710+ non_item_span,
711+ "consider using `const` instead of `let` for associated const" ,
712+ "const" ,
713+ Applicability :: MachineApplicable ,
714+ ) ;
715+ } else {
716+ err. span_label ( open_brace_span, "item list starts here" )
717+ . span_label ( non_item_span, "non-item starts here" )
718+ . span_label ( self . prev_token . span , "item list ends here" ) ;
719+ }
720+ if is_unnecessary_semicolon {
721+ err. span_suggestion (
722+ semicolon_span,
723+ "consider removing this semicolon" ,
724+ "" ,
725+ Applicability :: MaybeIncorrect ,
726+ ) ;
727+ }
728+ err. emit ( ) ;
722729 break ;
723730 }
724731 Ok ( Some ( item) ) => items. extend ( item) ,
0 commit comments