Skip to content

Commit 9bda4e4

Browse files
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... 🤔
2 parents 66a062a + 8e45d0f commit 9bda4e4

File tree

3 files changed

+27
-8
lines changed

3 files changed

+27
-8
lines changed

compiler/rustc_parse/src/parser/stmt.rs

+10-6
Original file line numberDiff line numberDiff line change
@@ -787,13 +787,17 @@ impl<'a> Parser<'a> {
787787
let suggest_eq = if self.token.kind == token::Dot
788788
&& let _ = self.bump()
789789
&& let mut snapshot = self.create_snapshot_for_diagnostic()
790-
&& let Ok(_) = snapshot.parse_dot_suffix_expr(
791-
colon_sp,
792-
self.mk_expr_err(
790+
&& let Ok(_) = snapshot
791+
.parse_dot_suffix_expr(
793792
colon_sp,
794-
self.dcx().delayed_bug("error during `:` -> `=` recovery"),
795-
),
796-
) {
793+
self.mk_expr_err(
794+
colon_sp,
795+
self.dcx()
796+
.delayed_bug("error during `:` -> `=` recovery"),
797+
),
798+
)
799+
.map_err(Diag::cancel)
800+
{
797801
true
798802
} else if let Some(op) = self.check_assoc_op()
799803
&& op.node.can_continue_expr_unambiguously()
Original file line numberDiff line numberDiff line change
@@ -1,3 +1,10 @@
1+
#![allow(unused)]
2+
3+
fn test_122112() {
4+
// Make sure we don't ICE if parsing in recovery fails
5+
let _: std::env::temp_dir().join(&self, push: Box<usize>); //~ ERROR expected one of
6+
}
7+
18
fn main() {
29
let _: std::env::temp_dir().join("foo"); //~ ERROR expected one of
310
}
Original file line numberDiff line numberDiff line change
@@ -1,11 +1,19 @@
11
error: expected one of `!`, `+`, `->`, `::`, `;`, or `=`, found `.`
2-
--> $DIR/recover-colon-instead-of-eq-in-local.rs:2:32
2+
--> $DIR/recover-colon-instead-of-eq-in-local.rs:5:32
3+
|
4+
LL | let _: std::env::temp_dir().join(&self, push: Box<usize>);
5+
| - ^ expected one of `!`, `+`, `->`, `::`, `;`, or `=`
6+
| |
7+
| while parsing the type for `_`
8+
9+
error: expected one of `!`, `+`, `->`, `::`, `;`, or `=`, found `.`
10+
--> $DIR/recover-colon-instead-of-eq-in-local.rs:9:32
311
|
412
LL | let _: std::env::temp_dir().join("foo");
513
| - ^ expected one of `!`, `+`, `->`, `::`, `;`, or `=`
614
| |
715
| while parsing the type for `_`
816
| help: use `=` if you meant to assign
917

10-
error: aborting due to 1 previous error
18+
error: aborting due to 2 previous errors
1119

0 commit comments

Comments
 (0)