@@ -142,16 +142,16 @@ impl<'tcx, M: Machine<'tcx>> InterpCx<'tcx, M> {
142142 let tag_val = tag_val. to_scalar ( ) ;
143143 // Compute the variant this niche value/"tag" corresponds to. With niche layout,
144144 // discriminant (encoded in niche/tag) and variant index are the same.
145- let variants_start = niche_variants. start ( ) . as_u32 ( ) ;
146- let variants_end = niche_variants. end ( ) . as_u32 ( ) ;
145+ let variants_start = niche_variants. start . as_u32 ( ) ;
146+ let variants_last = niche_variants. last . as_u32 ( ) ;
147147 let variant = match tag_val. try_to_scalar_int ( ) {
148148 Err ( dbg_val) => {
149149 // So this is a pointer then, and casting to an int failed.
150150 // Can only happen during CTFE.
151151 // The niche must be just 0, and the ptr not null, then we know this is
152152 // okay. Everything else, we conservatively reject.
153153 let ptr_valid = niche_start == 0
154- && variants_start == variants_end
154+ && variants_start == variants_last
155155 && !self . scalar_may_be_null ( tag_val) ?;
156156 if !ptr_valid {
157157 throw_ub ! ( InvalidTag ( dbg_val) )
@@ -169,7 +169,7 @@ impl<'tcx, M: Machine<'tcx>> InterpCx<'tcx, M> {
169169 let variant_index_relative =
170170 variant_index_relative_val. to_scalar ( ) . to_bits ( tag_val. layout . size ) ?;
171171 // Check if this is in the range that indicates an actual discriminant.
172- if variant_index_relative <= u128:: from ( variants_end - variants_start) {
172+ if variant_index_relative <= u128:: from ( variants_last - variants_start) {
173173 let variant_index_relative = u32:: try_from ( variant_index_relative)
174174 . expect ( "we checked that this fits into a u32" ) ;
175175 // Then computing the absolute variant idx should not overflow any more.
@@ -309,7 +309,7 @@ impl<'tcx, M: Machine<'tcx>> InterpCx<'tcx, M> {
309309 niche_variants. contains( & variant_index) ,
310310 "invalid variant index for this enum"
311311 ) ;
312- let variants_start = niche_variants. start ( ) . as_u32 ( ) ;
312+ let variants_start = niche_variants. start . as_u32 ( ) ;
313313 let variant_index_relative = variant_index. as_u32 ( ) . strict_sub ( variants_start) ;
314314 // We need to use machine arithmetic when taking into account `niche_start`:
315315 // tag_val = variant_index_relative + niche_start_val
0 commit comments