File tree Expand file tree Collapse file tree 3 files changed +33
-0
lines changed Expand file tree Collapse file tree 3 files changed +33
-0
lines changed Original file line number Diff line number Diff line change @@ -6722,6 +6722,22 @@ impl<'a> Parser<'a> {
67226722 self . expect ( & token:: OpenDelim ( token:: Brace ) ) ?;
67236723 let mut trait_items = vec ! [ ] ;
67246724 while !self . eat ( & token:: CloseDelim ( token:: Brace ) ) {
6725+ if let token:: DocComment ( _) = self . token {
6726+ if self . look_ahead ( 1 ,
6727+ |tok| tok == & token:: Token :: CloseDelim ( token:: Brace ) ) {
6728+ let mut err = self . diagnostic ( ) . struct_span_err_with_code (
6729+ self . span ,
6730+ "found a documentation comment that doesn't document anything" ,
6731+ DiagnosticId :: Error ( "E0584" . into ( ) ) ,
6732+ ) ;
6733+ err. help ( "doc comments must come before what they document, maybe a \
6734+ comment was intended with `//`?",
6735+ ) ;
6736+ err. emit ( ) ;
6737+ self . bump ( ) ;
6738+ continue ;
6739+ }
6740+ }
67256741 let mut at_end = false ;
67266742 match self . parse_trait_item ( & mut at_end) {
67276743 Ok ( item) => trait_items. push ( item) ,
Original file line number Diff line number Diff line change 1+ trait User {
2+ fn test ( ) ;
3+ /// empty doc
4+ //~^ ERROR found a documentation comment that doesn't document anything
5+ }
6+ fn main ( ) { }
Original file line number Diff line number Diff line change 1+ error[E0584]: found a documentation comment that doesn't document anything
2+ --> $DIR/doc-inside-trait-item.rs:3:5
3+ |
4+ LL | /// empty doc
5+ | ^^^^^^^^^^^^^
6+ |
7+ = help: doc comments must come before what they document, maybe a comment was intended with `//`?
8+
9+ error: aborting due to previous error
10+
11+ For more information about this error, try `rustc --explain E0584`.
You can’t perform that action at this time.
0 commit comments