Skip to content

Commit 47e42c8

Browse files
authored
Rollup merge of #133702 - RalfJung:single-variant, r=oli-obk
Variants::Single: do not use invalid VariantIdx for uninhabited enums ~~Stacked on top of rust-lang/rust#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
2 parents 3227f35 + a6cf662 commit 47e42c8

File tree

1 file changed

+2
-0
lines changed

1 file changed

+2
-0
lines changed

src/discriminant.rs

+2
Original file line numberDiff line numberDiff line change
@@ -18,6 +18,7 @@ pub(crate) fn codegen_set_discriminant<'tcx>(
1818
return;
1919
}
2020
match layout.variants {
21+
Variants::Empty => unreachable!("we already handled uninhabited types"),
2122
Variants::Single { index } => {
2223
assert_eq!(index, variant_index);
2324
}
@@ -85,6 +86,7 @@ pub(crate) fn codegen_get_discriminant<'tcx>(
8586
}
8687

8788
let (tag_scalar, tag_field, tag_encoding) = match &layout.variants {
89+
Variants::Empty => unreachable!("we already handled uninhabited types"),
8890
Variants::Single { index } => {
8991
let discr_val = layout
9092
.ty

0 commit comments

Comments
 (0)