1
Fork 0

Rollup merge of #122115 - clubby789:cancel-recoverr, r=compiler-errors

Cancel parsing ever made during recovery

Fixes #122112

It would be nice if diagnostics from recovery were automatically cancelled... 🤔
This commit is contained in:
Guillaume Gomez 2024-03-07 15:07:08 +01:00 committed by GitHub
commit 9bda4e47c7
No known key found for this signature in database
GPG key ID: B5690EEEBB952194
3 changed files with 27 additions and 8 deletions

View file

@ -787,13 +787,17 @@ impl<'a> Parser<'a> {
let suggest_eq = if self.token.kind == token::Dot
&& let _ = self.bump()
&& let mut snapshot = self.create_snapshot_for_diagnostic()
&& let Ok(_) = snapshot.parse_dot_suffix_expr(
colon_sp,
self.mk_expr_err(
&& let Ok(_) = snapshot
.parse_dot_suffix_expr(
colon_sp,
self.dcx().delayed_bug("error during `:` -> `=` recovery"),
),
) {
self.mk_expr_err(
colon_sp,
self.dcx()
.delayed_bug("error during `:` -> `=` recovery"),
),
)
.map_err(Diag::cancel)
{
true
} else if let Some(op) = self.check_assoc_op()
&& op.node.can_continue_expr_unambiguously()