Rollup merge of #62604 - estebank:unemitted-err-ice, r=pnkfelix
Handle errors during error recovery gracefully Fix #62546.
This commit is contained in:
commit
4fe6e63cd6
3 changed files with 27 additions and 4 deletions
|
@ -7410,10 +7410,13 @@ impl<'a> Parser<'a> {
|
||||||
} else if self.look_ahead(1, |t| *t == token::OpenDelim(token::Paren)) {
|
} else if self.look_ahead(1, |t| *t == token::OpenDelim(token::Paren)) {
|
||||||
let ident = self.parse_ident().unwrap();
|
let ident = self.parse_ident().unwrap();
|
||||||
self.bump(); // `(`
|
self.bump(); // `(`
|
||||||
let kw_name = if let Ok(Some(_)) = self.parse_self_arg_with_attrs() {
|
let kw_name = match self.parse_self_arg_with_attrs() {
|
||||||
"method"
|
Ok(Some(_)) => "method",
|
||||||
} else {
|
Ok(None) => "function",
|
||||||
"function"
|
Err(mut err) => {
|
||||||
|
err.cancel();
|
||||||
|
"function"
|
||||||
|
}
|
||||||
};
|
};
|
||||||
self.consume_block(token::Paren);
|
self.consume_block(token::Paren);
|
||||||
let (kw, kw_name, ambiguous) = if self.check(&token::RArrow) {
|
let (kw, kw_name, ambiguous) = if self.check(&token::RArrow) {
|
||||||
|
|
3
src/test/ui/parser/issue-62546.rs
Normal file
3
src/test/ui/parser/issue-62546.rs
Normal file
|
@ -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
src/test/ui/parser/issue-62546.stderr
Normal file
17
src/test/ui/parser/issue-62546.stderr
Normal file
|
@ -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
|
||||||
|
|
Loading…
Add table
Add a link
Reference in a new issue