Skip to content

Commit 944a142

Browse files
author
Michael Benfield
committed
Change name of "dataful" variant to "untagged"
This is in anticipation of a new enum layout, in which the niche optimization may be applied even when multiple variants have data.
1 parent 104168a commit 944a142

File tree

1 file changed

+6
-5
lines changed

1 file changed

+6
-5
lines changed

src/discriminant.rs

+6-5
Original file line numberDiff line numberDiff line change
@@ -42,10 +42,10 @@ pub(crate) fn codegen_set_discriminant<'tcx>(
4242
Variants::Multiple {
4343
tag: _,
4444
tag_field,
45-
tag_encoding: TagEncoding::Niche { dataful_variant, ref niche_variants, niche_start },
45+
tag_encoding: TagEncoding::Niche { untagged_variant, ref niche_variants, niche_start },
4646
variants: _,
4747
} => {
48-
if variant_index != dataful_variant {
48+
if variant_index != untagged_variant {
4949
let niche = place.place_field(fx, mir::Field::new(tag_field));
5050
let niche_value = variant_index.as_u32() - niche_variants.start().as_u32();
5151
let niche_value = ty::ScalarInt::try_from_uint(
@@ -113,7 +113,7 @@ pub(crate) fn codegen_get_discriminant<'tcx>(
113113
let res = CValue::by_val(val, dest_layout);
114114
dest.write_cvalue(fx, res);
115115
}
116-
TagEncoding::Niche { dataful_variant, ref niche_variants, niche_start } => {
116+
TagEncoding::Niche { untagged_variant, ref niche_variants, niche_start } => {
117117
// Rebase from niche values to discriminants, and check
118118
// whether the result is in range for the niche variants.
119119

@@ -169,8 +169,9 @@ pub(crate) fn codegen_get_discriminant<'tcx>(
169169
fx.bcx.ins().iadd_imm(relative_discr, i64::from(niche_variants.start().as_u32()))
170170
};
171171

172-
let dataful_variant = fx.bcx.ins().iconst(cast_to, i64::from(dataful_variant.as_u32()));
173-
let discr = fx.bcx.ins().select(is_niche, niche_discr, dataful_variant);
172+
let untagged_variant =
173+
fx.bcx.ins().iconst(cast_to, i64::from(untagged_variant.as_u32()));
174+
let discr = fx.bcx.ins().select(is_niche, niche_discr, untagged_variant);
174175
let res = CValue::by_val(discr, dest_layout);
175176
dest.write_cvalue(fx, res);
176177
}

0 commit comments

Comments
 (0)