@@ -4483,13 +4483,17 @@ impl<'a> Parser<'a> {
44834483 }
44844484
44854485 /// Emit an expected item after attributes error.
4486- fn expected_item_err ( & self , attrs : & [ Attribute ] ) {
4486+ fn expected_item_err ( & mut self , attrs : & [ Attribute ] ) -> PResult < ' a , ( ) > {
44874487 let message = match attrs. last ( ) {
44884488 Some ( & Attribute { is_sugared_doc : true , .. } ) => "expected item after doc comment" ,
44894489 _ => "expected item after attributes" ,
44904490 } ;
44914491
4492- self . span_err ( self . prev_span , message) ;
4492+ let mut err = self . diagnostic ( ) . struct_span_err ( self . prev_span , message) ;
4493+ if attrs. last ( ) . unwrap ( ) . is_sugared_doc {
4494+ err. span_label ( self . prev_span , "this doc comment doesn't document anything" ) ;
4495+ }
4496+ Err ( err)
44934497 }
44944498
44954499 /// Parse a statement. This stops just before trailing semicolons on everything but items.
@@ -7636,7 +7640,7 @@ impl<'a> Parser<'a> {
76367640 }
76377641 None => {
76387642 if !attrs. is_empty ( ) {
7639- self . expected_item_err ( & attrs) ;
7643+ self . expected_item_err ( & attrs) ? ;
76407644 }
76417645
76427646 self . unexpected ( )
@@ -7699,7 +7703,7 @@ impl<'a> Parser<'a> {
76997703 }
77007704
77017705 if !attributes_allowed && !attrs. is_empty ( ) {
7702- self . expected_item_err ( & attrs) ;
7706+ self . expected_item_err ( & attrs) ? ;
77037707 }
77047708 Ok ( None )
77057709 }
0 commit comments