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
|
@ -212,21 +212,18 @@ pub(super) fn build_enum_type_di_node<'ll, 'tcx>(
|
|||
),
|
||||
|cx, enum_type_di_node| {
|
||||
match enum_type_and_layout.variants {
|
||||
Variants::Single { index: variant_index } => {
|
||||
let Some(variant_index) = variant_index else {
|
||||
// Uninhabited enums have Variants::Single. We don't generate
|
||||
// any members for them.
|
||||
return smallvec![];
|
||||
};
|
||||
|
||||
build_single_variant_union_fields(
|
||||
cx,
|
||||
enum_adt_def,
|
||||
enum_type_and_layout,
|
||||
enum_type_di_node,
|
||||
variant_index,
|
||||
)
|
||||
Variants::Empty => {
|
||||
// Uninhabited enums have Variants::Single. We don't generate
|
||||
// any members for them.
|
||||
return smallvec![];
|
||||
}
|
||||
Variants::Single { index: variant_index } => build_single_variant_union_fields(
|
||||
cx,
|
||||
enum_adt_def,
|
||||
enum_type_and_layout,
|
||||
enum_type_di_node,
|
||||
variant_index,
|
||||
),
|
||||
Variants::Multiple {
|
||||
tag_encoding: TagEncoding::Direct,
|
||||
ref variants,
|
||||
|
@ -303,6 +300,7 @@ pub(super) fn build_coroutine_di_node<'ll, 'tcx>(
|
|||
)
|
||||
}
|
||||
Variants::Single { .. }
|
||||
| Variants::Empty
|
||||
| Variants::Multiple { tag_encoding: TagEncoding::Niche { .. }, .. } => {
|
||||
bug!(
|
||||
"Encountered coroutine with non-direct-tag layout: {:?}",
|
||||
|
|
|
@ -392,7 +392,7 @@ fn compute_discriminant_value<'ll, 'tcx>(
|
|||
variant_index: VariantIdx,
|
||||
) -> DiscrResult {
|
||||
match enum_type_and_layout.layout.variants() {
|
||||
&Variants::Single { .. } => DiscrResult::NoDiscriminant,
|
||||
&Variants::Single { .. } | &Variants::Empty => DiscrResult::NoDiscriminant,
|
||||
&Variants::Multiple { tag_encoding: TagEncoding::Direct, .. } => DiscrResult::Value(
|
||||
enum_type_and_layout.ty.discriminant_for_variant(cx.tcx, variant_index).unwrap().val,
|
||||
),
|
||||
|
|
|
@ -358,8 +358,8 @@ fn build_discr_member_di_node<'ll, 'tcx>(
|
|||
let containing_scope = enum_or_coroutine_type_di_node;
|
||||
|
||||
match enum_or_coroutine_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_field, .. } => {
|
||||
let tag_base_type = tag_base_type(cx.tcx, enum_or_coroutine_type_and_layout);
|
||||
|
|
|
@ -35,14 +35,14 @@ fn uncached_llvm_type<'a, 'tcx>(
|
|||
if !cx.sess().fewer_names() =>
|
||||
{
|
||||
let mut name = with_no_visible_paths!(with_no_trimmed_paths!(layout.ty.to_string()));
|
||||
if let (&ty::Adt(def, _), &Variants::Single { index: Some(index) }) =
|
||||
if let (&ty::Adt(def, _), &Variants::Single { index }) =
|
||||
(layout.ty.kind(), &layout.variants)
|
||||
{
|
||||
if def.is_enum() {
|
||||
write!(&mut name, "::{}", def.variant(index).name).unwrap();
|
||||
}
|
||||
}
|
||||
if let (&ty::Coroutine(_, _), &Variants::Single { index: Some(index) }) =
|
||||
if let (&ty::Coroutine(_, _), &Variants::Single { index }) =
|
||||
(layout.ty.kind(), &layout.variants)
|
||||
{
|
||||
write!(&mut name, "::{}", ty::CoroutineArgs::variant_name(index)).unwrap();
|
||||
|
@ -216,7 +216,7 @@ impl<'tcx> LayoutLlvmExt<'tcx> for TyAndLayout<'tcx> {
|
|||
|
||||
// Check the cache.
|
||||
let variant_index = match self.variants {
|
||||
Variants::Single { index } => index,
|
||||
Variants::Single { index } => Some(index),
|
||||
_ => None,
|
||||
};
|
||||
if let Some(llty) = cx.type_lowering.borrow().get(&(self.ty, variant_index)) {
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue