Remove assumption from recovery code
This commit is contained in:
parent
a2bbf7deba
commit
30b779f398
3 changed files with 17 additions and 1 deletions
|
@ -8366,11 +8366,11 @@ impl<'a> Parser<'a> {
|
||||||
} else {
|
} else {
|
||||||
("fn` or `struct", "function or struct", true)
|
("fn` or `struct", "function or struct", true)
|
||||||
};
|
};
|
||||||
self.consume_block(token::Brace);
|
|
||||||
|
|
||||||
let msg = format!("missing `{}` for {} definition", kw, kw_name);
|
let msg = format!("missing `{}` for {} definition", kw, kw_name);
|
||||||
let mut err = self.diagnostic().struct_span_err(sp, &msg);
|
let mut err = self.diagnostic().struct_span_err(sp, &msg);
|
||||||
if !ambiguous {
|
if !ambiguous {
|
||||||
|
self.consume_block(token::Brace);
|
||||||
let suggestion = format!("add `{}` here to parse `{}` as a public {}",
|
let suggestion = format!("add `{}` here to parse `{}` as a public {}",
|
||||||
kw,
|
kw,
|
||||||
ident,
|
ident,
|
||||||
|
|
8
src/test/ui/pub/pub-ident-fn-3.rs
Normal file
8
src/test/ui/pub/pub-ident-fn-3.rs
Normal file
|
@ -0,0 +1,8 @@
|
||||||
|
// #60115
|
||||||
|
|
||||||
|
mod foo {
|
||||||
|
pub bar();
|
||||||
|
//~^ ERROR missing `fn` or `struct` for function or struct definition
|
||||||
|
}
|
||||||
|
|
||||||
|
fn main() {}
|
8
src/test/ui/pub/pub-ident-fn-3.stderr
Normal file
8
src/test/ui/pub/pub-ident-fn-3.stderr
Normal 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
|
||||||
|
|
Loading…
Add table
Add a link
Reference in a new issue