diff options
| author | Matthias Krüger <matthias.krueger@famsik.de> | 2024-04-07 00:51:26 +0200 |
|---|---|---|
| committer | GitHub <noreply@github.com> | 2024-04-07 00:51:26 +0200 |
| commit | f51ce75af4e6e7e1e132e2dff1dfc959f9f358a2 (patch) | |
| tree | 83b4510eeeb4a9a903edf5a9d5f21690ff548c7d | |
| parent | 84dca1503e5268bd8a30a46576cff7b7541154eb (diff) | |
| parent | 97ea48ce326fc60973700297cce07980ca76d1f2 (diff) | |
| download | rust-f51ce75af4e6e7e1e132e2dff1dfc959f9f358a2.tar.gz rust-f51ce75af4e6e7e1e132e2dff1dfc959f9f358a2.zip | |
Rollup merge of #123516 - estebank:issue-123428, r=compiler-errors
Do not ICE on field access check on expr with `ty::Error` Fix #123428
| -rw-r--r-- | compiler/rustc_passes/src/dead.rs | 3 | ||||
| -rw-r--r-- | tests/ui/consts/do-not-ice-on-field-access-of-err-type.rs | 9 | ||||
| -rw-r--r-- | tests/ui/consts/do-not-ice-on-field-access-of-err-type.stderr | 17 |
3 files changed, 28 insertions, 1 deletions
diff --git a/compiler/rustc_passes/src/dead.rs b/compiler/rustc_passes/src/dead.rs index 80f2078fff2..51f288b3c95 100644 --- a/compiler/rustc_passes/src/dead.rs +++ b/compiler/rustc_passes/src/dead.rs @@ -153,7 +153,8 @@ impl<'tcx> MarkSymbolVisitor<'tcx> { self.insert_def_id(def.non_enum_variant().fields[index].did); } ty::Tuple(..) => {} - _ => span_bug!(lhs.span, "named field access on non-ADT"), + ty::Error(_) => {} + kind => span_bug!(lhs.span, "named field access on non-ADT: {kind:?}"), } } diff --git a/tests/ui/consts/do-not-ice-on-field-access-of-err-type.rs b/tests/ui/consts/do-not-ice-on-field-access-of-err-type.rs new file mode 100644 index 00000000000..a2e336b703e --- /dev/null +++ b/tests/ui/consts/do-not-ice-on-field-access-of-err-type.rs @@ -0,0 +1,9 @@ +trait Foo {} +impl<T> Foo for T {} + +fn main() { + let array = [(); { loop {} }]; //~ ERROR constant evaluation is taking a long time + + let tup = (7,); + let x: &dyn Foo = &tup.0; +} diff --git a/tests/ui/consts/do-not-ice-on-field-access-of-err-type.stderr b/tests/ui/consts/do-not-ice-on-field-access-of-err-type.stderr new file mode 100644 index 00000000000..02b8904fbde --- /dev/null +++ b/tests/ui/consts/do-not-ice-on-field-access-of-err-type.stderr @@ -0,0 +1,17 @@ +error: constant evaluation is taking a long time + --> $DIR/do-not-ice-on-field-access-of-err-type.rs:5:24 + | +LL | let array = [(); { loop {} }]; + | ^^^^^^^ + | + = note: this lint makes sure the compiler doesn't get stuck due to infinite loops in const eval. + If your compilation actually takes a long time, you can safely allow the lint. +help: the constant being evaluated + --> $DIR/do-not-ice-on-field-access-of-err-type.rs:5:22 + | +LL | let array = [(); { loop {} }]; + | ^^^^^^^^^^^ + = note: `#[deny(long_running_const_eval)]` on by default + +error: aborting due to 1 previous error + |
