From c8401a504646eefdd46de66732d8da58adca9a25 Mon Sep 17 00:00:00 2001 From: LeSeulArtichaut Date: Sat, 29 Feb 2020 14:19:48 +0100 Subject: [PATCH 1/2] Do not ICE on invalid type node --- src/librustc_typeck/check/expr.rs | 1 + 1 file changed, 1 insertion(+) diff --git a/src/librustc_typeck/check/expr.rs b/src/librustc_typeck/check/expr.rs index 38d73256469fe..146155217490b 100644 --- a/src/librustc_typeck/check/expr.rs +++ b/src/librustc_typeck/check/expr.rs @@ -1312,6 +1312,7 @@ impl<'a, 'tcx> FnCtxt<'a, 'tcx> { ty_span: Span, ) { if variant.recovered { + self.set_tainted_by_errors(); return; } let mut err = self.type_error_struct_with_diag( From febf72861bf00599225250c9d2550a1c4eddbd08 Mon Sep 17 00:00:00 2001 From: LeSeulArtichaut Date: Sat, 29 Feb 2020 14:38:39 +0100 Subject: [PATCH 2/2] Add regression test --- ...ssue-69378-ice-on-invalid-type-node-after-recovery.rs | 9 +++++++++ ...-69378-ice-on-invalid-type-node-after-recovery.stderr | 8 ++++++++ 2 files changed, 17 insertions(+) create mode 100644 src/test/ui/typeck/issue-69378-ice-on-invalid-type-node-after-recovery.rs create mode 100644 src/test/ui/typeck/issue-69378-ice-on-invalid-type-node-after-recovery.stderr diff --git a/src/test/ui/typeck/issue-69378-ice-on-invalid-type-node-after-recovery.rs b/src/test/ui/typeck/issue-69378-ice-on-invalid-type-node-after-recovery.rs new file mode 100644 index 0000000000000..571692a5374da --- /dev/null +++ b/src/test/ui/typeck/issue-69378-ice-on-invalid-type-node-after-recovery.rs @@ -0,0 +1,9 @@ +// Regression test for #69378: no type for node after struct parse recovery + +struct Foo { 0: u8 } //~ ERROR expected identifier + +fn test(f: Foo) { + Foo{foo: 4, ..f}; +} + +fn main() {} diff --git a/src/test/ui/typeck/issue-69378-ice-on-invalid-type-node-after-recovery.stderr b/src/test/ui/typeck/issue-69378-ice-on-invalid-type-node-after-recovery.stderr new file mode 100644 index 0000000000000..6bc9c8498c9d1 --- /dev/null +++ b/src/test/ui/typeck/issue-69378-ice-on-invalid-type-node-after-recovery.stderr @@ -0,0 +1,8 @@ +error: expected identifier, found `0` + --> $DIR/issue-69378-ice-on-invalid-type-node-after-recovery.rs:3:14 + | +LL | struct Foo { 0: u8 } + | ^ expected identifier + +error: aborting due to previous error +