Skip to content

Commit

Permalink
Rollup merge of rust-lang#123516 - estebank:issue-123428, r=compiler-…
Browse files Browse the repository at this point in the history
…errors

Do not ICE on field access check on expr with `ty::Error`

Fix rust-lang#123428
  • Loading branch information
GuillaumeGomez committed Apr 6, 2024
2 parents cc8c3ae + 97ea48c commit 7aa78df
Show file tree
Hide file tree
Showing 3 changed files with 28 additions and 1 deletion.
3 changes: 2 additions & 1 deletion compiler/rustc_passes/src/dead.rs
Expand Up @@ -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:?}"),
}
}

Expand Down
9 changes: 9 additions & 0 deletions 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;
}
17 changes: 17 additions & 0 deletions 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

0 comments on commit 7aa78df

Please sign in to comment.