Skip to content

Commit fcfc796

Browse files
author
Saleem Jaffer
committed
fixes #56766
1 parent 88f755f commit fcfc796

File tree

1 file changed

+16
-0
lines changed

1 file changed

+16
-0
lines changed

src/libsyntax/parse/parser.rs

+16
Original file line numberDiff line numberDiff line change
@@ -6630,6 +6630,22 @@ impl<'a> Parser<'a> {
66306630
self.expect(&token::OpenDelim(token::Brace))?;
66316631
let mut trait_items = vec![];
66326632
while !self.eat(&token::CloseDelim(token::Brace)) {
6633+
if let token::DocComment(_) = self.token {
6634+
if self.look_ahead(1,
6635+
|tok| tok == &token::Token::CloseDelim(token::Brace)) {
6636+
let mut err = self.diagnostic().struct_span_err_with_code(
6637+
self.span,
6638+
"found a documentation comment that doesn't document anything",
6639+
DiagnosticId::Error("E0584".into()),
6640+
);
6641+
err.help("doc comments must come before what they document, maybe a \
6642+
comment was intended with `//`?",
6643+
);
6644+
err.emit();
6645+
self.bump();
6646+
continue;
6647+
}
6648+
}
66336649
let mut at_end = false;
66346650
match self.parse_trait_item(&mut at_end) {
66356651
Ok(item) => trait_items.push(item),

0 commit comments

Comments
 (0)