Skip to content

Commit 06a271a

Browse files
committed
Auto merge of #60119 - estebank:bad-recovery, r=davidtwco
Remove assumption from recovery code Fix #60115.
2 parents 4d9c6cd + 30b779f commit 06a271a

File tree

3 files changed

+17
-1
lines changed

3 files changed

+17
-1
lines changed

src/libsyntax/parse/parser.rs

+1-1
Original file line numberDiff line numberDiff line change
@@ -8414,11 +8414,11 @@ impl<'a> Parser<'a> {
84148414
} else {
84158415
("fn` or `struct", "function or struct", true)
84168416
};
8417-
self.consume_block(token::Brace);
84188417

84198418
let msg = format!("missing `{}` for {} definition", kw, kw_name);
84208419
let mut err = self.diagnostic().struct_span_err(sp, &msg);
84218420
if !ambiguous {
8421+
self.consume_block(token::Brace);
84228422
let suggestion = format!("add `{}` here to parse `{}` as a public {}",
84238423
kw,
84248424
ident,

src/test/ui/pub/pub-ident-fn-3.rs

+8
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,8 @@
1+
// #60115
2+
3+
mod foo {
4+
pub bar();
5+
//~^ ERROR missing `fn` or `struct` for function or struct definition
6+
}
7+
8+
fn main() {}

src/test/ui/pub/pub-ident-fn-3.stderr

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

0 commit comments

Comments
 (0)