Auto merge of #60119 - estebank:bad-recovery, r=davidtwco

Remove assumption from recovery code

Fix #60115.
This commit is contained in:
bors 2019-04-21 10:13:27 +00:00
commit 06a271a6eb
3 changed files with 17 additions and 1 deletions

View file

@ -8414,11 +8414,11 @@ impl<'a> Parser<'a> {
} else {
("fn` or `struct", "function or struct", true)
};
self.consume_block(token::Brace);
let msg = format!("missing `{}` for {} definition", kw, kw_name);
let mut err = self.diagnostic().struct_span_err(sp, &msg);
if !ambiguous {
self.consume_block(token::Brace);
let suggestion = format!("add `{}` here to parse `{}` as a public {}",
kw,
ident,

View file

@ -0,0 +1,8 @@
// #60115
mod foo {
pub bar();
//~^ ERROR missing `fn` or `struct` for function or struct definition
}
fn main() {}

View file

@ -0,0 +1,8 @@
error: missing `fn` or `struct` for function or struct definition
--> $DIR/pub-ident-fn-3.rs:4:8
|
LL | pub bar();
| ---^--- help: if you meant to call a macro, try: `bar!`
error: aborting due to previous error