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
This commit is contained in:
commit
2a43ce03fb
33 changed files with 186 additions and 165 deletions
|
@ -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
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue