Skip to content

Commit 57d0559

Browse files
committed
Change tag_field to FieldIdx in Variants::Multiple
It was already available as a generic parameter anyway, and it's not like we'll ever put a tag in the 5-billionth field.
1 parent 112e5e8 commit 57d0559

File tree

1 file changed

+3
-3
lines changed

1 file changed

+3
-3
lines changed

src/discriminant.rs

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -28,7 +28,7 @@ pub(crate) fn codegen_set_discriminant<'tcx>(
2828
tag_encoding: TagEncoding::Direct,
2929
variants: _,
3030
} => {
31-
let ptr = place.place_field(fx, FieldIdx::new(tag_field));
31+
let ptr = place.place_field(fx, tag_field);
3232
let to = layout.ty.discriminant_for_variant(fx.tcx, variant_index).unwrap().val;
3333
let to = match ptr.layout().ty.kind() {
3434
ty::Uint(UintTy::U128) | ty::Int(IntTy::I128) => {
@@ -53,7 +53,7 @@ pub(crate) fn codegen_set_discriminant<'tcx>(
5353
variants: _,
5454
} => {
5555
if variant_index != untagged_variant {
56-
let niche = place.place_field(fx, FieldIdx::new(tag_field));
56+
let niche = place.place_field(fx, tag_field);
5757
let niche_type = fx.clif_type(niche.layout().ty).unwrap();
5858
let niche_value = variant_index.as_u32() - niche_variants.start().as_u32();
5959
let niche_value = (niche_value as u128).wrapping_add(niche_start);
@@ -118,7 +118,7 @@ pub(crate) fn codegen_get_discriminant<'tcx>(
118118
let cast_to = fx.clif_type(dest_layout.ty).unwrap();
119119

120120
// Read the tag/niche-encoded discriminant from memory.
121-
let tag = value.value_field(fx, FieldIdx::new(tag_field));
121+
let tag = value.value_field(fx, tag_field);
122122
let tag = tag.load_scalar(fx);
123123

124124
// Decode the discriminant (specifically if it's niche-encoded).

0 commit comments

Comments
 (0)