Skip to content

Remove assumption from recovery code #60119

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Merged
merged 1 commit into from
Apr 21, 2019
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
2 changes: 1 addition & 1 deletion src/libsyntax/parse/parser.rs
Original file line number Diff line number Diff line change
Expand Up @@ -8366,11 +8366,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,
Expand Down
8 changes: 8 additions & 0 deletions src/test/ui/pub/pub-ident-fn-3.rs
Original file line number Diff line number Diff line change
@@ -0,0 +1,8 @@
// #60115

mod foo {
pub bar();
//~^ ERROR missing `fn` or `struct` for function or struct definition
}

fn main() {}
8 changes: 8 additions & 0 deletions src/test/ui/pub/pub-ident-fn-3.stderr
Original file line number Diff line number Diff line change
@@ -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