Skip to content

Commit

Permalink
Rollup merge of rust-lang#62666 - estebank:preempt-ice, r=eddyb
Browse files Browse the repository at this point in the history
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
  • Loading branch information
Mark-Simulacrum authored Jul 16, 2019
2 parents 02785da + f05dfe0 commit ae26723
Showing 1 changed file with 9 additions and 8 deletions.
17 changes: 9 additions & 8 deletions src/libsyntax/parse/parser.rs
Original file line number Diff line number Diff line change
Expand Up @@ -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) {
Expand Down Expand Up @@ -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)
Expand Down

0 comments on commit ae26723

Please sign in to comment.