Skip to content

Commit 8643006

Browse files
Rollup merge of rust-lang#157139 - scottmcm:abi-range-inclusive, r=oli-obk
compiler: `ops::RangeInclusive` → `range::RangeInclusive` The type's been stable for over 6 weeks now, so let's use it! It's better for cases like this one where it's stored in a data structure. Probably won't be materially faster, but does make the variant slightly smaller and lets some more things be `Copy`. And deletes a whole bunch of parens from things being fields instead of methods 😄 r? compiler
2 parents 56d26b3 + 9b4b659 commit 8643006

1 file changed

Lines changed: 4 additions & 4 deletions

File tree

src/discriminant.rs

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -55,7 +55,7 @@ pub(crate) fn codegen_set_discriminant<'tcx>(
5555
if variant_index != untagged_variant {
5656
let niche = place.place_field(fx, tag_field);
5757
let niche_type = fx.clif_type(niche.layout().ty).unwrap();
58-
let niche_value = variant_index.as_u32() - niche_variants.start().as_u32();
58+
let niche_value = variant_index.as_u32() - niche_variants.start.as_u32();
5959
let niche_value = (niche_value as u128).wrapping_add(niche_start);
6060
let niche_value = match niche_type {
6161
types::I128 => {
@@ -133,7 +133,7 @@ pub(crate) fn codegen_get_discriminant<'tcx>(
133133
dest.write_cvalue(fx, res);
134134
}
135135
TagEncoding::Niche { untagged_variant, ref niche_variants, niche_start } => {
136-
let relative_max = niche_variants.end().as_u32() - niche_variants.start().as_u32();
136+
let relative_max = niche_variants.last.as_u32() - niche_variants.start.as_u32();
137137

138138
// We have a subrange `niche_start..=niche_end` inside `range`.
139139
// If the value of the tag is inside this subrange, it's a
@@ -162,7 +162,7 @@ pub(crate) fn codegen_get_discriminant<'tcx>(
162162
// }
163163
let is_niche = codegen_icmp_imm(fx, IntCC::Equal, tag, niche_start as i128);
164164
let tagged_discr =
165-
fx.bcx.ins().iconst(cast_to, niche_variants.start().as_u32() as i64);
165+
fx.bcx.ins().iconst(cast_to, niche_variants.start.as_u32() as i64);
166166
(is_niche, tagged_discr, 0)
167167
} else {
168168
// The special cases don't apply, so we'll have to go with
@@ -184,7 +184,7 @@ pub(crate) fn codegen_get_discriminant<'tcx>(
184184
relative_discr,
185185
i128::from(relative_max),
186186
);
187-
(is_niche, cast_tag, niche_variants.start().as_u32() as u128)
187+
(is_niche, cast_tag, niche_variants.start.as_u32() as u128)
188188
};
189189

190190
let tagged_discr = if delta == 0 {

0 commit comments

Comments
 (0)