diff options
| author | Ralf Jung <post@ralfj.de> | 2024-11-30 19:33:23 +0100 |
|---|---|---|
| committer | Ralf Jung <post@ralfj.de> | 2024-12-01 18:28:04 +0100 |
| commit | 611a99188e86bdff0cb7c2e1806eff77fedc54b1 (patch) | |
| tree | 2a629ed5fcc27a26aaa374ecb907eddcbc299058 /compiler/rustc_const_eval/src/interpret | |
| parent | a36652c274e25802230e5188bceab8a92a3e7346 (diff) | |
| download | rust-611a99188e86bdff0cb7c2e1806eff77fedc54b1.tar.gz rust-611a99188e86bdff0cb7c2e1806eff77fedc54b1.zip | |
fix safe-transmute handling of enums
Diffstat (limited to 'compiler/rustc_const_eval/src/interpret')
| -rw-r--r-- | compiler/rustc_const_eval/src/interpret/discriminant.rs | 2 |
1 files changed, 1 insertions, 1 deletions
diff --git a/compiler/rustc_const_eval/src/interpret/discriminant.rs b/compiler/rustc_const_eval/src/interpret/discriminant.rs index c7c8a2902e2..6faac1582ab 100644 --- a/compiler/rustc_const_eval/src/interpret/discriminant.rs +++ b/compiler/rustc_const_eval/src/interpret/discriminant.rs @@ -70,7 +70,7 @@ impl<'tcx, M: Machine<'tcx>> InterpCx<'tcx, M> { if ty.is_enum() { // Hilariously, `Single` is used even for 0-variant enums. // (See https://github.com/rust-lang/rust/issues/89765). - if matches!(ty.kind(), ty::Adt(def, ..) if def.variants().is_empty()) { + if ty.ty_adt_def().unwrap().variants().is_empty() { throw_ub!(UninhabitedEnumVariantRead(index)) } // For consistency with `write_discriminant`, and to make sure that |
