@@ -409,7 +409,7 @@ fn trans_scalar<'tcx>(
409
409
span : Span ,
410
410
ty : TyAndLayout < ' tcx > ,
411
411
scalar : & Scalar ,
412
- index : Option < usize > ,
412
+ scalar_pair_field_index : Option < usize > ,
413
413
is_immediate : bool ,
414
414
) -> Word {
415
415
if is_immediate && scalar. is_bool ( ) {
@@ -423,7 +423,7 @@ fn trans_scalar<'tcx>(
423
423
Primitive :: F32 => SpirvType :: Float ( 32 ) . def ( span, cx) ,
424
424
Primitive :: F64 => SpirvType :: Float ( 64 ) . def ( span, cx) ,
425
425
Primitive :: Pointer => {
426
- let pointee_ty = dig_scalar_pointee ( cx, ty, index ) ;
426
+ let pointee_ty = dig_scalar_pointee ( cx, ty, scalar_pair_field_index ) ;
427
427
// Pointers can be recursive. So, record what we're currently translating, and if we're already translating
428
428
// the same type, emit an OpTypeForwardPointer and use that ID.
429
429
if let Some ( predefined_result) = cx
@@ -455,16 +455,16 @@ fn trans_scalar<'tcx>(
455
455
fn dig_scalar_pointee < ' tcx > (
456
456
cx : & CodegenCx < ' tcx > ,
457
457
ty : TyAndLayout < ' tcx > ,
458
- index : Option < usize > ,
458
+ scalar_pair_field_index : Option < usize > ,
459
459
) -> PointeeTy < ' tcx > {
460
460
match * ty. ty . kind ( ) {
461
461
TyKind :: Ref ( _, elem_ty, _) | TyKind :: RawPtr ( TypeAndMut { ty : elem_ty, .. } ) => {
462
462
let elem = cx. layout_of ( elem_ty) ;
463
- match index {
463
+ match scalar_pair_field_index {
464
464
None => PointeeTy :: Ty ( elem) ,
465
- Some ( index ) => {
465
+ Some ( scalar_pair_field_index ) => {
466
466
if elem. is_unsized ( ) {
467
- dig_scalar_pointee ( cx, ty. field ( cx, index ) , None )
467
+ dig_scalar_pointee ( cx, ty. field ( cx, scalar_pair_field_index ) , None )
468
468
} else {
469
469
// This can sometimes happen in weird cases when going through the Adt case below - an ABI
470
470
// of ScalarPair could be deduced, but it's actually e.g. a sized pointer followed by some other
@@ -475,25 +475,25 @@ fn dig_scalar_pointee<'tcx>(
475
475
}
476
476
}
477
477
}
478
- TyKind :: FnPtr ( sig) if index . is_none ( ) => PointeeTy :: Fn ( sig) ,
478
+ TyKind :: FnPtr ( sig) if scalar_pair_field_index . is_none ( ) => PointeeTy :: Fn ( sig) ,
479
479
TyKind :: Adt ( def, _) if def. is_box ( ) => {
480
480
let ptr_ty = cx. layout_of ( cx. tcx . mk_mut_ptr ( ty. ty . boxed_ty ( ) ) ) ;
481
- dig_scalar_pointee ( cx, ptr_ty, index )
481
+ dig_scalar_pointee ( cx, ptr_ty, scalar_pair_field_index )
482
482
}
483
483
TyKind :: Tuple ( _) | TyKind :: Adt ( ..) | TyKind :: Closure ( ..) => {
484
- dig_scalar_pointee_adt ( cx, ty, index )
484
+ dig_scalar_pointee_adt ( cx, ty, scalar_pair_field_index )
485
485
}
486
486
ref kind => cx. tcx . sess . fatal ( & format ! (
487
- "TODO: Unimplemented Primitive::Pointer TyKind index ={:?} ({:#?}):\n {:#?}" ,
488
- index , kind, ty
487
+ "TODO: Unimplemented Primitive::Pointer TyKind scalar_pair_field_index ={:?} ({:#?}):\n {:#?}" ,
488
+ scalar_pair_field_index , kind, ty
489
489
) ) ,
490
490
}
491
491
}
492
492
493
493
fn dig_scalar_pointee_adt < ' tcx > (
494
494
cx : & CodegenCx < ' tcx > ,
495
495
ty : TyAndLayout < ' tcx > ,
496
- index : Option < usize > ,
496
+ scalar_pair_field_index : Option < usize > ,
497
497
) -> PointeeTy < ' tcx > {
498
498
match & ty. variants {
499
499
// If it's a Variants::Multiple, then we want to emit the type of the dataful variant, not the type of the
@@ -519,7 +519,7 @@ fn dig_scalar_pointee_adt<'tcx>(
519
519
assert_eq ! ( 1 , adt. variants[ dataful_variant] . fields. len( ) ) ;
520
520
assert_eq ! ( 0 , * tag_field) ;
521
521
let field_ty = adt. variants [ dataful_variant] . fields [ 0 ] . ty ( cx. tcx , substs) ;
522
- dig_scalar_pointee ( cx, cx. layout_of ( field_ty) , index )
522
+ dig_scalar_pointee ( cx, cx. layout_of ( field_ty) , scalar_pair_field_index )
523
523
} else {
524
524
bug ! ( "Variants::Multiple not TyKind::Adt: {:#?}" , ty)
525
525
}
@@ -533,11 +533,11 @@ fn dig_scalar_pointee_adt<'tcx>(
533
533
. map ( |f| ty. field ( cx, f) )
534
534
. filter ( |f| !f. is_zst ( ) )
535
535
. collect :: < Vec < _ > > ( ) ;
536
- match index {
537
- Some ( index ) => match fields. len ( ) {
538
- 1 => dig_scalar_pointee ( cx, fields[ 0 ] , Some ( index ) ) ,
536
+ match scalar_pair_field_index {
537
+ Some ( scalar_pair_field_index ) => match fields. len ( ) {
538
+ 1 => dig_scalar_pointee ( cx, fields[ 0 ] , Some ( scalar_pair_field_index ) ) ,
539
539
// This case right here is the cause of the comment handling TyKind::Ref.
540
- 2 => dig_scalar_pointee ( cx, fields[ index ] , None ) ,
540
+ 2 => dig_scalar_pointee ( cx, fields[ scalar_pair_field_index ] , None ) ,
541
541
other => cx. tcx . sess . fatal ( & format ! (
542
542
"Unable to dig scalar pair pointer type: fields length {}" ,
543
543
other
0 commit comments