diff options
| author | bors <bors@rust-lang.org> | 2024-02-08 10:05:39 +0000 |
|---|---|---|
| committer | bors <bors@rust-lang.org> | 2024-02-08 10:05:39 +0000 |
| commit | af88f7db51f6f2a1472f9279d7c7e7c822afff77 (patch) | |
| tree | d3c047d15985d02a3d7b69c47df8af5bbab4bfd9 /compiler/rustc_parse/src | |
| parent | 81bef0b0ba78f9b7bb08beb0575e245fbe18674a (diff) | |
| parent | eab2adb6607d94fd0c70de93abf546ae9282afaa (diff) | |
| download | rust-af88f7db51f6f2a1472f9279d7c7e7c822afff77.tar.gz rust-af88f7db51f6f2a1472f9279d7c7e7c822afff77.zip | |
Auto merge of #120550 - oli-obk:track_errors8, r=estebank
Continue to borrowck even if there were previous errors but only from the perspective of the whole compiler. Individual items should not get borrowcked if their MIR is tainted by errors. r? `@estebank` `@nnethercote`
Diffstat (limited to 'compiler/rustc_parse/src')
| -rw-r--r-- | compiler/rustc_parse/src/parser/expr.rs | 12 |
1 files changed, 11 insertions, 1 deletions
diff --git a/compiler/rustc_parse/src/parser/expr.rs b/compiler/rustc_parse/src/parser/expr.rs index e36a648e203..1a57474bac2 100644 --- a/compiler/rustc_parse/src/parser/expr.rs +++ b/compiler/rustc_parse/src/parser/expr.rs @@ -2911,12 +2911,22 @@ impl<'a> Parser<'a> { Ok(arm) => arms.push(arm), Err(e) => { // Recover by skipping to the end of the block. - e.emit(); + let guar = e.emit(); self.recover_stmt(); let span = lo.to(self.token.span); if self.token == token::CloseDelim(Delimiter::Brace) { self.bump(); } + // Always push at least one arm to make the match non-empty + arms.push(Arm { + attrs: Default::default(), + pat: self.mk_pat(span, ast::PatKind::Err(guar)), + guard: None, + body: Some(self.mk_expr_err(span)), + span, + id: DUMMY_NODE_ID, + is_placeholder: false, + }); return Ok(self.mk_expr_with_attrs( span, ExprKind::Match(scrutinee, arms), |
