diff options
| author | Mark Rousskov <mark.simulacrum@gmail.com> | 2019-07-16 11:38:52 -0400 |
|---|---|---|
| committer | GitHub <noreply@github.com> | 2019-07-16 11:38:52 -0400 |
| commit | ae2672340cf8e4243b99a59c7f01b663a4d4dc78 (patch) | |
| tree | 44f5ef1d592fa7b12d6a3d18cb0ecafa957146e3 /src/libsyntax/parse/parser.rs | |
| parent | 02785dabad07d19b8c76a7f86763801d5d3497ff (diff) | |
| parent | f05dfe07f69cc126ee6c4132394b78d36e93c0d0 (diff) | |
| download | rust-ae2672340cf8e4243b99a59c7f01b663a4d4dc78.tar.gz rust-ae2672340cf8e4243b99a59c7f01b663a4d4dc78.zip | |
Rollup merge of #62666 - estebank:preempt-ice, r=eddyb
Cancel unemitted diagnostics during error recovery Follow up to https://github.com/rust-lang/rust/pull/62604. Use @eddyb's preferred style and catch other case of the same problem. r? @eddyb
Diffstat (limited to 'src/libsyntax/parse/parser.rs')
| -rw-r--r-- | src/libsyntax/parse/parser.rs | 17 |
1 files changed, 9 insertions, 8 deletions
diff --git a/src/libsyntax/parse/parser.rs b/src/libsyntax/parse/parser.rs index 050b614d147..1d4d02c7325 100644 --- a/src/libsyntax/parse/parser.rs +++ b/src/libsyntax/parse/parser.rs @@ -7418,13 +7418,12 @@ 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 = match self.parse_self_arg_with_attrs() { - Ok(Some(_)) => "method", - Ok(None) => "function", - Err(mut err) => { - err.cancel(); - "function" - } + let kw_name = if let Ok(Some(_)) = self.parse_self_arg_with_attrs() + .map_err(|mut e| e.cancel()) + { + "method" + } else { + "function" }; self.consume_block(token::Paren); let (kw, kw_name, ambiguous) = if self.check(&token::RArrow) { @@ -7472,7 +7471,9 @@ impl<'a> Parser<'a> { self.eat_to_tokens(&[&token::Gt]); self.bump(); // `>` let (kw, kw_name, ambiguous) = if self.eat(&token::OpenDelim(token::Paren)) { - if let Ok(Some(_)) = self.parse_self_arg_with_attrs() { + if let Ok(Some(_)) = self.parse_self_arg_with_attrs() + .map_err(|mut e| e.cancel()) + { ("fn", "method", false) } else { ("fn", "function", false) |
