Handle errors during error recovery gracefully

This commit is contained in:
Esteban Küber
2019-07-11 16:54:33 -07:00
parent 4bb6b4a5ed
commit e1c7747cf0
3 changed files with 27 additions and 4 deletions

View File

@@ -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();
"function"
}
};
self.consume_block(token::Paren);
let (kw, kw_name, ambiguous) = if self.check(&token::RArrow) {