File tree 3 files changed +34
-1
lines changed
3 files changed +34
-1
lines changed Original file line number Diff line number Diff line change @@ -5940,6 +5940,14 @@ impl<'a> Parser<'a> {
5940
5940
self . expect ( & token:: OpenDelim ( token:: Brace ) ) ?;
5941
5941
let mut trait_items = vec ! [ ] ;
5942
5942
while !self . eat ( & token:: CloseDelim ( token:: Brace ) ) {
5943
+ if let token:: DocComment ( _) = self . token {
5944
+ if self . look_ahead ( 1 , |tok| tok == & token:: Token :: CloseDelim ( token:: Brace ) ) {
5945
+ self . span_fatal_err ( self . span , Error :: UselessDocComment ) . emit ( ) ;
5946
+ self . bump ( ) ;
5947
+ continue ;
5948
+ }
5949
+ }
5950
+
5943
5951
let mut at_end = false ;
5944
5952
match self . parse_trait_item ( & mut at_end) {
5945
5953
Ok ( item) => trait_items. push ( item) ,
@@ -7676,7 +7684,7 @@ impl<'a> Parser<'a> {
7676
7684
& mut self . token_cursor . stack [ prev] . last_token
7677
7685
} ;
7678
7686
7679
- // Pull our the toekns that we've collected from the call to `f` above
7687
+ // Pull our the tokens that we've collected from the call to `f` above
7680
7688
let mut collected_tokens = match * last_token {
7681
7689
LastToken :: Collecting ( ref mut v) => mem:: replace ( v, Vec :: new ( ) ) ,
7682
7690
LastToken :: Was ( _) => panic ! ( "our vector went away?" ) ,
Original file line number Diff line number Diff line change
1
+ //! issue #56766
2
+ //!
3
+ //! invalid doc comment at the end of a trait declaration
4
+
5
+ trait Foo {
6
+ ///
7
+ fn foo ( & self ) ;
8
+ /// I am not documenting anything
9
+ //~^ ERROR: found a documentation comment that doesn't document anything [E0585]
10
+ }
11
+
12
+ fn main ( ) {
13
+
14
+ }
Original file line number Diff line number Diff line change
1
+ error[E0585]: found a documentation comment that doesn't document anything
2
+ --> $DIR/trait-impl.rs:8:5
3
+ |
4
+ LL | /// I am not documenting anything
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 E0585`.
You can’t perform that action at this time.
0 commit comments