@@ -5,8 +5,9 @@ use hir::def_id::DefId;
5
5
use rustc_abi:: Integer :: { I8 , I32 } ;
6
6
use rustc_abi:: Primitive :: { self , Float , Int , Pointer } ;
7
7
use rustc_abi:: {
8
- Abi , AbiAndPrefAlign , AddressSpace , Align , FieldsShape , HasDataLayout , LayoutCalculatorError ,
9
- LayoutS , Niche , ReprOptions , Scalar , Size , StructKind , TagEncoding , Variants , WrappingRange ,
8
+ AbiAndPrefAlign , AddressSpace , Align , FieldsShape , HasDataLayout , IrForm ,
9
+ LayoutCalculatorError , LayoutS , Niche , ReprOptions , Scalar , Size , StructKind , TagEncoding ,
10
+ Variants , WrappingRange ,
10
11
} ;
11
12
use rustc_index:: bit_set:: BitSet ;
12
13
use rustc_index:: { IndexSlice , IndexVec } ;
@@ -173,7 +174,9 @@ fn layout_of_uncached<'tcx>(
173
174
let mut layout = LayoutS :: clone ( & layout. 0 ) ;
174
175
match * pat {
175
176
ty:: PatternKind :: Range { start, end, include_end } => {
176
- if let Abi :: Scalar ( scalar) | Abi :: ScalarPair ( scalar, _) = & mut layout. abi {
177
+ if let IrForm :: Scalar ( scalar) | IrForm :: ScalarPair ( scalar, _) =
178
+ & mut layout. ir_form
179
+ {
177
180
if let Some ( start) = start {
178
181
scalar. valid_range_mut ( ) . start = start
179
182
. try_to_bits ( tcx, param_env)
@@ -275,7 +278,7 @@ fn layout_of_uncached<'tcx>(
275
278
return Ok ( tcx. mk_layout ( LayoutS :: scalar ( cx, data_ptr) ) ) ;
276
279
}
277
280
278
- let Abi :: Scalar ( metadata) = metadata_layout. abi else {
281
+ let IrForm :: Scalar ( metadata) = metadata_layout. ir_form else {
279
282
return Err ( error ( cx, LayoutError :: Unknown ( pointee) ) ) ;
280
283
} ;
281
284
@@ -330,17 +333,17 @@ fn layout_of_uncached<'tcx>(
330
333
. ok_or_else ( || error ( cx, LayoutError :: SizeOverflow ( ty) ) ) ?;
331
334
332
335
let abi = if count != 0 && ty. is_privately_uninhabited ( tcx, param_env) {
333
- Abi :: Uninhabited
336
+ IrForm :: Uninhabited
334
337
} else {
335
- Abi :: Aggregate { sized : true }
338
+ IrForm :: Memory { sized : true }
336
339
} ;
337
340
338
341
let largest_niche = if count != 0 { element. largest_niche } else { None } ;
339
342
340
343
tcx. mk_layout ( LayoutS {
341
344
variants : Variants :: Single { index : FIRST_VARIANT } ,
342
345
fields : FieldsShape :: Array { stride : element. size , count } ,
343
- abi,
346
+ ir_form : abi,
344
347
largest_niche,
345
348
align : element. align ,
346
349
size,
@@ -353,7 +356,7 @@ fn layout_of_uncached<'tcx>(
353
356
tcx. mk_layout ( LayoutS {
354
357
variants : Variants :: Single { index : FIRST_VARIANT } ,
355
358
fields : FieldsShape :: Array { stride : element. size , count : 0 } ,
356
- abi : Abi :: Aggregate { sized : false } ,
359
+ ir_form : IrForm :: Memory { sized : false } ,
357
360
largest_niche : None ,
358
361
align : element. align ,
359
362
size : Size :: ZERO ,
@@ -364,7 +367,7 @@ fn layout_of_uncached<'tcx>(
364
367
ty:: Str => tcx. mk_layout ( LayoutS {
365
368
variants : Variants :: Single { index : FIRST_VARIANT } ,
366
369
fields : FieldsShape :: Array { stride : Size :: from_bytes ( 1 ) , count : 0 } ,
367
- abi : Abi :: Aggregate { sized : false } ,
370
+ ir_form : IrForm :: Memory { sized : false } ,
368
371
largest_niche : None ,
369
372
align : dl. i8_align ,
370
373
size : Size :: ZERO ,
@@ -384,8 +387,8 @@ fn layout_of_uncached<'tcx>(
384
387
& ReprOptions :: default ( ) ,
385
388
StructKind :: AlwaysSized ,
386
389
) ?;
387
- match unit. abi {
388
- Abi :: Aggregate { ref mut sized } => * sized = false ,
390
+ match unit. ir_form {
391
+ IrForm :: Memory { ref mut sized } => * sized = false ,
389
392
_ => bug ! ( ) ,
390
393
}
391
394
tcx. mk_layout ( unit)
@@ -500,7 +503,7 @@ fn layout_of_uncached<'tcx>(
500
503
501
504
// Compute the ABI of the element type:
502
505
let e_ly = cx. layout_of ( e_ty) ?;
503
- let Abi :: Scalar ( e_abi) = e_ly. abi else {
506
+ let IrForm :: Scalar ( e_abi) = e_ly. ir_form else {
504
507
// This error isn't caught in typeck, e.g., if
505
508
// the element type of the vector is generic.
506
509
tcx. dcx ( ) . emit_fatal ( NonPrimitiveSimdType { ty, e_ty } ) ;
@@ -516,12 +519,12 @@ fn layout_of_uncached<'tcx>(
516
519
// Non-power-of-two vectors have padding up to the next power-of-two.
517
520
// If we're a packed repr, remove the padding while keeping the alignment as close
518
521
// to a vector as possible.
519
- ( Abi :: Aggregate { sized : true } , AbiAndPrefAlign {
522
+ ( IrForm :: Memory { sized : true } , AbiAndPrefAlign {
520
523
abi : Align :: max_for_offset ( size) ,
521
524
pref : dl. vector_align ( size) . pref ,
522
525
} )
523
526
} else {
524
- ( Abi :: Vector { element : e_abi, count : e_len } , dl. vector_align ( size) )
527
+ ( IrForm :: Vector { element : e_abi, count : e_len } , dl. vector_align ( size) )
525
528
} ;
526
529
let size = size. align_to ( align. abi ) ;
527
530
@@ -535,7 +538,7 @@ fn layout_of_uncached<'tcx>(
535
538
tcx. mk_layout ( LayoutS {
536
539
variants : Variants :: Single { index : FIRST_VARIANT } ,
537
540
fields,
538
- abi,
541
+ ir_form : abi,
539
542
largest_niche : e_ly. largest_niche ,
540
543
size,
541
544
align,
@@ -985,11 +988,12 @@ fn coroutine_layout<'tcx>(
985
988
986
989
size = size. align_to ( align. abi ) ;
987
990
988
- let abi = if prefix. abi . is_uninhabited ( ) || variants. iter ( ) . all ( |v| v. abi . is_uninhabited ( ) ) {
989
- Abi :: Uninhabited
990
- } else {
991
- Abi :: Aggregate { sized : true }
992
- } ;
991
+ let abi =
992
+ if prefix. ir_form . is_uninhabited ( ) || variants. iter ( ) . all ( |v| v. ir_form . is_uninhabited ( ) ) {
993
+ IrForm :: Uninhabited
994
+ } else {
995
+ IrForm :: Memory { sized : true }
996
+ } ;
993
997
994
998
let layout = tcx. mk_layout ( LayoutS {
995
999
variants : Variants :: Multiple {
@@ -999,7 +1003,7 @@ fn coroutine_layout<'tcx>(
999
1003
variants,
1000
1004
} ,
1001
1005
fields : outer_fields,
1002
- abi,
1006
+ ir_form : abi,
1003
1007
// Suppress niches inside coroutines. If the niche is inside a field that is aliased (due to
1004
1008
// self-referentiality), getting the discriminant can cause aliasing violations.
1005
1009
// `UnsafeCell` blocks niches for the same reason, but we don't yet have `UnsafePinned` that
0 commit comments