Skip to content

Commit ae26723

Browse files
Rollup merge of rust-lang#62666 - estebank:preempt-ice, r=eddyb
Cancel unemitted diagnostics during error recovery Follow up to rust-lang#62604. Use @eddyb's preferred style and catch other case of the same problem. r? @eddyb
2 parents 02785da + f05dfe0 commit ae26723

File tree

1 file changed

+9
-8
lines changed

1 file changed

+9
-8
lines changed

src/libsyntax/parse/parser.rs

+9-8
Original file line numberDiff line numberDiff line change
@@ -7418,13 +7418,12 @@ impl<'a> Parser<'a> {
74187418
} else if self.look_ahead(1, |t| *t == token::OpenDelim(token::Paren)) {
74197419
let ident = self.parse_ident().unwrap();
74207420
self.bump(); // `(`
7421-
let kw_name = match self.parse_self_arg_with_attrs() {
7422-
Ok(Some(_)) => "method",
7423-
Ok(None) => "function",
7424-
Err(mut err) => {
7425-
err.cancel();
7426-
"function"
7427-
}
7421+
let kw_name = if let Ok(Some(_)) = self.parse_self_arg_with_attrs()
7422+
.map_err(|mut e| e.cancel())
7423+
{
7424+
"method"
7425+
} else {
7426+
"function"
74287427
};
74297428
self.consume_block(token::Paren);
74307429
let (kw, kw_name, ambiguous) = if self.check(&token::RArrow) {
@@ -7472,7 +7471,9 @@ impl<'a> Parser<'a> {
74727471
self.eat_to_tokens(&[&token::Gt]);
74737472
self.bump(); // `>`
74747473
let (kw, kw_name, ambiguous) = if self.eat(&token::OpenDelim(token::Paren)) {
7475-
if let Ok(Some(_)) = self.parse_self_arg_with_attrs() {
7474+
if let Ok(Some(_)) = self.parse_self_arg_with_attrs()
7475+
.map_err(|mut e| e.cancel())
7476+
{
74767477
("fn", "method", false)
74777478
} else {
74787479
("fn", "function", false)

0 commit comments

Comments
 (0)