diff options
| author | 许杰友 Jieyou Xu (Joe) <39484203+jieyouxu@users.noreply.github.com> | 2024-12-19 16:48:07 +0800 |
|---|---|---|
| committer | GitHub <noreply@github.com> | 2024-12-19 16:48:07 +0800 |
| commit | 2a43ce03fb60736880477e985d7bd13e3ff65b3d (patch) | |
| tree | 4e4bb271114119c1cb923700f08b9c956d37e3da /compiler/rustc_codegen_cranelift/src | |
| parent | bab18a542d95b5c76620d0a0d383d7ab683cc1b7 (diff) | |
| parent | 397ae3cdf641b8d303ab9d004013f956c2991727 (diff) | |
| download | rust-2a43ce03fb60736880477e985d7bd13e3ff65b3d.tar.gz rust-2a43ce03fb60736880477e985d7bd13e3ff65b3d.zip | |
Rollup merge of #133702 - RalfJung:single-variant, r=oli-obk
Variants::Single: do not use invalid VariantIdx for uninhabited enums ~~Stacked on top of https://github.com/rust-lang/rust/pull/133681, only the last commit is new.~~ Currently, `Variants::Single` for an empty enum contains a `VariantIdx` of 0; looking that up in the enum variant list will ICE. That's quite confusing. So let's fix that by adding a new `Variants::Empty` case for types that have 0 variants. try-job: i686-msvc
Diffstat (limited to 'compiler/rustc_codegen_cranelift/src')
| -rw-r--r-- | compiler/rustc_codegen_cranelift/src/discriminant.rs | 2 |
1 files changed, 2 insertions, 0 deletions
diff --git a/compiler/rustc_codegen_cranelift/src/discriminant.rs b/compiler/rustc_codegen_cranelift/src/discriminant.rs index 45794a42665..4d0d5dc60eb 100644 --- a/compiler/rustc_codegen_cranelift/src/discriminant.rs +++ b/compiler/rustc_codegen_cranelift/src/discriminant.rs @@ -18,6 +18,7 @@ pub(crate) fn codegen_set_discriminant<'tcx>( return; } match layout.variants { + Variants::Empty => unreachable!("we already handled uninhabited types"), Variants::Single { index } => { assert_eq!(index, variant_index); } @@ -85,6 +86,7 @@ pub(crate) fn codegen_get_discriminant<'tcx>( } let (tag_scalar, tag_field, tag_encoding) = match &layout.variants { + Variants::Empty => unreachable!("we already handled uninhabited types"), Variants::Single { index } => { let discr_val = layout .ty |
