mirror of
https://github.com/rust-lang/rust.git
synced 2025-02-11 22:43:42 +00:00
Consume trailing doc comments to avoid parse errors
This commit is contained in:
parent
0e93b75d27
commit
f103342b8f
@ -5422,9 +5422,8 @@ impl<'a> Parser<'a> {
|
||||
token::CloseDelim(token::Brace) => {}
|
||||
token::DocComment(_) => {
|
||||
let mut err = self.span_fatal_err(self.span, Error::UselessDocComment);
|
||||
if self.eat(&token::Comma) ||
|
||||
self.look_ahead(1, |t| *t == token::CloseDelim(token::Brace))
|
||||
{
|
||||
self.bump(); // consume the doc comment
|
||||
if self.eat(&token::Comma) || self.token == token::CloseDelim(token::Brace) {
|
||||
err.emit();
|
||||
} else {
|
||||
return Err(err);
|
||||
|
@ -9,12 +9,20 @@
|
||||
// except according to those terms.
|
||||
|
||||
// compile-flags: -Z continue-parse-after-error
|
||||
|
||||
struct X {
|
||||
a: u8 /** document a */,
|
||||
//~^ ERROR found a documentation comment that doesn't document anything
|
||||
//~| HELP maybe a comment was intended
|
||||
}
|
||||
|
||||
fn main() {
|
||||
let y = X {a: 1};
|
||||
struct Y {
|
||||
a: u8 /// document a
|
||||
//~^ ERROR found a documentation comment that doesn't document anything
|
||||
//~| HELP maybe a comment was intended
|
||||
}
|
||||
|
||||
fn main() {
|
||||
let x = X { a: 1 };
|
||||
let y = Y { a: 1 };
|
||||
}
|
||||
|
@ -11,7 +11,7 @@
|
||||
macro_rules! failed {
|
||||
() => {{
|
||||
let x = 5 ""; //~ ERROR found `""`
|
||||
}} //~ ERROR macro expansion ignores token `}`
|
||||
}}
|
||||
}
|
||||
|
||||
fn main() {
|
||||
|
Loading…
Reference in New Issue
Block a user