@@ -4483,13 +4483,17 @@ impl<'a> Parser<'a> {
4483
4483
}
4484
4484
4485
4485
/// 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 , ( ) > {
4487
4487
let message = match attrs. last ( ) {
4488
4488
Some ( & Attribute { is_sugared_doc : true , .. } ) => "expected item after doc comment" ,
4489
4489
_ => "expected item after attributes" ,
4490
4490
} ;
4491
4491
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)
4493
4497
}
4494
4498
4495
4499
/// Parse a statement. This stops just before trailing semicolons on everything but items.
@@ -7636,7 +7640,7 @@ impl<'a> Parser<'a> {
7636
7640
}
7637
7641
None => {
7638
7642
if !attrs. is_empty ( ) {
7639
- self . expected_item_err ( & attrs) ;
7643
+ self . expected_item_err ( & attrs) ? ;
7640
7644
}
7641
7645
7642
7646
self . unexpected ( )
@@ -7699,7 +7703,7 @@ impl<'a> Parser<'a> {
7699
7703
}
7700
7704
7701
7705
if !attributes_allowed && !attrs. is_empty ( ) {
7702
- self . expected_item_err ( & attrs) ;
7706
+ self . expected_item_err ( & attrs) ? ;
7703
7707
}
7704
7708
Ok ( None )
7705
7709
}
0 commit comments