make no-variant types a dedicated Variants variant
This commit is contained in:
parent
21de42bf8d
commit
e023590de4
53 changed files with 246 additions and 495 deletions
|
@ -65,8 +65,8 @@ fn tag_base_type_opt<'tcx>(
|
|||
});
|
||||
|
||||
match enum_type_and_layout.layout.variants() {
|
||||
// A single-variant enum has no discriminant.
|
||||
Variants::Single { .. } => None,
|
||||
// A single-variant or no-variant enum has no discriminant.
|
||||
Variants::Single { .. } | Variants::Empty => None,
|
||||
|
||||
Variants::Multiple { tag_encoding: TagEncoding::Niche { .. }, tag, .. } => {
|
||||
// Niche tags are always normalized to unsized integers of the correct size.
|
||||
|
|
|
@ -243,8 +243,8 @@ impl<'a, 'tcx, V: CodegenObject> PlaceRef<'tcx, V> {
|
|||
return bx.cx().const_poison(cast_to);
|
||||
}
|
||||
let (tag_scalar, tag_encoding, tag_field) = match self.layout.variants {
|
||||
Variants::Empty => unreachable!("we already handled uninhabited types"),
|
||||
Variants::Single { index } => {
|
||||
let index = index.unwrap(); // we already checked `is_uninhabited`
|
||||
let discr_val = self
|
||||
.layout
|
||||
.ty
|
||||
|
@ -366,9 +366,9 @@ impl<'a, 'tcx, V: CodegenObject> PlaceRef<'tcx, V> {
|
|||
return;
|
||||
}
|
||||
match self.layout.variants {
|
||||
Variants::Single { index } => {
|
||||
assert_eq!(index.unwrap(), variant_index);
|
||||
}
|
||||
Variants::Empty => unreachable!("we already handled uninhabited types"),
|
||||
Variants::Single { index } => assert_eq!(index, variant_index),
|
||||
|
||||
Variants::Multiple { tag_encoding: TagEncoding::Direct, tag_field, .. } => {
|
||||
let ptr = self.project_field(bx, tag_field);
|
||||
let to =
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue