Skip to content

Commit

Permalink
Browse files Browse the repository at this point in the history
  • Loading branch information
lcnr committed Jan 8, 2019
1 parent ec19464 commit 512b3d0
Show file tree
Hide file tree
Showing 3 changed files with 34 additions and 1 deletion.
10 changes: 9 additions & 1 deletion src/libsyntax/parse/parser.rs
Original file line number Diff line number Diff line change
Expand Up @@ -5940,6 +5940,14 @@ impl<'a> Parser<'a> {
self.expect(&token::OpenDelim(token::Brace))?;
let mut trait_items = vec![];
while !self.eat(&token::CloseDelim(token::Brace)) {
if let token::DocComment(_) = self.token {
if self.look_ahead(1, |tok| tok == &token::Token::CloseDelim(token::Brace)) {
self.span_fatal_err(self.span, Error::UselessDocComment).emit();
self.bump();
continue;
}
}

let mut at_end = false;
match self.parse_trait_item(&mut at_end) {
Ok(item) => trait_items.push(item),
Expand Down Expand Up @@ -7676,7 +7684,7 @@ impl<'a> Parser<'a> {
&mut self.token_cursor.stack[prev].last_token
};

// Pull our the toekns that we've collected from the call to `f` above
// Pull our the tokens that we've collected from the call to `f` above
let mut collected_tokens = match *last_token {
LastToken::Collecting(ref mut v) => mem::replace(v, Vec::new()),
LastToken::Was(_) => panic!("our vector went away?"),
Expand Down
14 changes: 14 additions & 0 deletions src/test/ui/useless-doc-comment/trait-impl.rs
Original file line number Diff line number Diff line change
@@ -0,0 +1,14 @@
//! issue #56766
//!
//! invalid doc comment at the end of a trait declaration

trait Foo {
///
fn foo(&self);
/// I am not documenting anything
//~^ ERROR: found a documentation comment that doesn't document anything [E0585]
}

fn main() {

}
11 changes: 11 additions & 0 deletions src/test/ui/useless-doc-comment/trait-impl.stderr
Original file line number Diff line number Diff line change
@@ -0,0 +1,11 @@
error[E0585]: found a documentation comment that doesn't document anything
--> $DIR/trait-impl.rs:8:5
|
LL | /// I am not documenting anything
| ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
|
= help: doc comments must come before what they document, maybe a comment was intended with `//`?

error: aborting due to previous error

For more information about this error, try `rustc --explain E0585`.

0 comments on commit 512b3d0

Please sign in to comment.