Skip to content

Commit

Permalink
Remove a DiagnosticBuilder::emit_without_consuming call.
Browse files Browse the repository at this point in the history
In this parsing recovery function, we only need to emit the previously
obtained error message and mark `expr` as erroneous in the case where we
actually recover.
  • Loading branch information
nnethercote committed Jan 8, 2024
1 parent 6682f24 commit 1881055
Showing 1 changed file with 7 additions and 4 deletions.
11 changes: 7 additions & 4 deletions compiler/rustc_parse/src/parser/diagnostics.rs
Original file line number Diff line number Diff line change
Expand Up @@ -1212,29 +1212,32 @@ impl<'a> Parser<'a> {
match x {
Ok((_, _, false)) => {
if self.eat(&token::Gt) {
// We made sense of it. Improve the error message.
e.span_suggestion_verbose(
binop.span.shrink_to_lo(),
fluent::parse_sugg_turbofish_syntax,
"::",
Applicability::MaybeIncorrect,
)
.emit_without_consuming();
);
match self.parse_expr() {
Ok(_) => {
// The subsequent expression is valid. Mark
// `expr` as erroneous and emit `e` now, but
// return `Ok` so parsing can continue.
e.emit();
*expr = self.mk_expr_err(expr.span.to(self.prev_token.span));
return Ok(());
}
Err(err) => {
*expr = self.mk_expr_err(expr.span);
err.cancel();
}
}
}
}
Ok((_, _, true)) => {}
Err(err) => {
err.cancel();
}
_ => {}
}
}
Err(e)
Expand Down

0 comments on commit 1881055

Please sign in to comment.