Skip to content
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
11 changes: 7 additions & 4 deletions src/libsyntax/parse/parser.rs
Original file line number Diff line number Diff line change
Expand Up @@ -7408,10 +7408,13 @@ impl<'a> Parser<'a> {
} else if self.look_ahead(1, |t| *t == token::OpenDelim(token::Paren)) {
let ident = self.parse_ident().unwrap();
self.bump(); // `(`
let kw_name = if let Ok(Some(_)) = self.parse_self_arg_with_attrs() {
"method"
} else {
"function"
let kw_name = match self.parse_self_arg_with_attrs() {
Ok(Some(_)) => "method",
Ok(None) => "function",
Err(mut err) => {
err.cancel();
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

You could also use .map_err(|e| e.cancel()).

"function"
}
};
self.consume_block(token::Paren);
let (kw, kw_name, ambiguous) = if self.check(&token::RArrow) {
Expand Down
3 changes: 3 additions & 0 deletions src/test/ui/parser/issue-62546.rs
Original file line number Diff line number Diff line change
@@ -0,0 +1,3 @@
pub t(#
//~^ ERROR missing `fn` or `struct` for function or struct definition
//~ ERROR this file contains an un-closed delimiter
17 changes: 17 additions & 0 deletions src/test/ui/parser/issue-62546.stderr
Original file line number Diff line number Diff line change
@@ -0,0 +1,17 @@
error: this file contains an un-closed delimiter
--> $DIR/issue-62546.rs:3:53
|
LL | pub t(#
| - un-closed delimiter
LL |
LL |
| ^

error: missing `fn` or `struct` for function or struct definition
--> $DIR/issue-62546.rs:1:4
|
LL | pub t(#
| ---^- help: if you meant to call a macro, try: `t!`

error: aborting due to 2 previous errors