Skip to content

Commit 2c3f8b8

Browse files
estebankpietroalbini
authored andcommitted
Cancel unemitted diagnostics during error recovery
1 parent 620ed3a commit 2c3f8b8

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
@@ -7455,13 +7455,12 @@ impl<'a> Parser<'a> {
74557455
} else if self.look_ahead(1, |t| *t == token::OpenDelim(token::Paren)) {
74567456
let ident = self.parse_ident().unwrap();
74577457
self.bump(); // `(`
7458-
let kw_name = match self.parse_self_arg_with_attrs() {
7459-
Ok(Some(_)) => "method",
7460-
Ok(None) => "function",
7461-
Err(mut err) => {
7462-
err.cancel();
7463-
"function"
7464-
}
7458+
let kw_name = if let Ok(Some(_)) = self.parse_self_arg_with_attrs()
7459+
.map_err(|mut e| e.cancel())
7460+
{
7461+
"method"
7462+
} else {
7463+
"function"
74657464
};
74667465
self.consume_block(token::Paren);
74677466
let (kw, kw_name, ambiguous) = if self.check(&token::RArrow) {
@@ -7509,7 +7508,9 @@ impl<'a> Parser<'a> {
75097508
self.eat_to_tokens(&[&token::Gt]);
75107509
self.bump(); // `>`
75117510
let (kw, kw_name, ambiguous) = if self.eat(&token::OpenDelim(token::Paren)) {
7512-
if let Ok(Some(_)) = self.parse_self_arg_with_attrs() {
7511+
if let Ok(Some(_)) = self.parse_self_arg_with_attrs()
7512+
.map_err(|mut e| e.cancel())
7513+
{
75137514
("fn", "method", false)
75147515
} else {
75157516
("fn", "function", false)

0 commit comments

Comments
 (0)