@@ -183,7 +183,7 @@ impl<'tcx> fmt::Display for LayoutError<'tcx> {
183
183
fn layout_raw < ' tcx > (
184
184
tcx : TyCtxt < ' tcx > ,
185
185
query : ty:: ParamEnvAnd < ' tcx , Ty < ' tcx > > ,
186
- ) -> Result < & ' tcx LayoutDetails , LayoutError < ' tcx > > {
186
+ ) -> Result < & ' tcx Layout , LayoutError < ' tcx > > {
187
187
ty:: tls:: with_related_context ( tcx, move |icx| {
188
188
let rec_limit = * tcx. sess . recursion_limit . get ( ) ;
189
189
let ( param_env, ty) = query. into_parts ( ) ;
@@ -242,7 +242,7 @@ fn invert_mapping(map: &[u32]) -> Vec<u32> {
242
242
}
243
243
244
244
impl < ' tcx > LayoutCx < ' tcx , TyCtxt < ' tcx > > {
245
- fn scalar_pair ( & self , a : Scalar , b : Scalar ) -> LayoutDetails {
245
+ fn scalar_pair ( & self , a : Scalar , b : Scalar ) -> Layout {
246
246
let dl = self . data_layout ( ) ;
247
247
let b_align = b. value . align ( dl) ;
248
248
let align = a. value . align ( dl) . max ( b_align) . max ( dl. aggregate_align ) ;
@@ -256,7 +256,7 @@ impl<'tcx> LayoutCx<'tcx, TyCtxt<'tcx>> {
256
256
. chain ( Niche :: from_scalar ( dl, Size :: ZERO , a. clone ( ) ) )
257
257
. max_by_key ( |niche| niche. available ( dl) ) ;
258
258
259
- LayoutDetails {
259
+ Layout {
260
260
variants : Variants :: Single { index : VariantIdx :: new ( 0 ) } ,
261
261
fields : FieldPlacement :: Arbitrary {
262
262
offsets : vec ! [ Size :: ZERO , b_offset] ,
@@ -275,7 +275,7 @@ impl<'tcx> LayoutCx<'tcx, TyCtxt<'tcx>> {
275
275
fields : & [ TyLayout < ' _ > ] ,
276
276
repr : & ReprOptions ,
277
277
kind : StructKind ,
278
- ) -> Result < LayoutDetails , LayoutError < ' tcx > > {
278
+ ) -> Result < Layout , LayoutError < ' tcx > > {
279
279
let dl = self . data_layout ( ) ;
280
280
let pack = repr. pack ;
281
281
if pack. is_some ( ) && repr. align . is_some ( ) {
@@ -428,17 +428,11 @@ impl<'tcx> LayoutCx<'tcx, TyCtxt<'tcx>> {
428
428
(
429
429
Some ( (
430
430
i,
431
- & TyLayout {
432
- details : & LayoutDetails { abi : Abi :: Scalar ( ref a) , .. } ,
433
- ..
434
- } ,
431
+ & TyLayout { layout : & Layout { abi : Abi :: Scalar ( ref a) , .. } , .. } ,
435
432
) ) ,
436
433
Some ( (
437
434
j,
438
- & TyLayout {
439
- details : & LayoutDetails { abi : Abi :: Scalar ( ref b) , .. } ,
440
- ..
441
- } ,
435
+ & TyLayout { layout : & Layout { abi : Abi :: Scalar ( ref b) , .. } , .. } ,
442
436
) ) ,
443
437
None ,
444
438
) => {
@@ -476,7 +470,7 @@ impl<'tcx> LayoutCx<'tcx, TyCtxt<'tcx>> {
476
470
abi = Abi :: Uninhabited ;
477
471
}
478
472
479
- Ok ( LayoutDetails {
473
+ Ok ( Layout {
480
474
variants : Variants :: Single { index : VariantIdx :: new ( 0 ) } ,
481
475
fields : FieldPlacement :: Arbitrary { offsets, memory_index } ,
482
476
abi,
@@ -486,7 +480,7 @@ impl<'tcx> LayoutCx<'tcx, TyCtxt<'tcx>> {
486
480
} )
487
481
}
488
482
489
- fn layout_raw_uncached ( & self , ty : Ty < ' tcx > ) -> Result < & ' tcx LayoutDetails , LayoutError < ' tcx > > {
483
+ fn layout_raw_uncached ( & self , ty : Ty < ' tcx > ) -> Result < & ' tcx Layout , LayoutError < ' tcx > > {
490
484
let tcx = self . tcx ;
491
485
let param_env = self . param_env ;
492
486
let dl = self . data_layout ( ) ;
@@ -495,8 +489,7 @@ impl<'tcx> LayoutCx<'tcx, TyCtxt<'tcx>> {
495
489
assert ! ( bits <= 128 ) ;
496
490
Scalar { value, valid_range : 0 ..=( !0 >> ( 128 - bits) ) }
497
491
} ;
498
- let scalar =
499
- |value : Primitive | tcx. intern_layout ( LayoutDetails :: scalar ( self , scalar_unit ( value) ) ) ;
492
+ let scalar = |value : Primitive | tcx. intern_layout ( Layout :: scalar ( self , scalar_unit ( value) ) ) ;
500
493
501
494
let univariant = |fields : & [ TyLayout < ' _ > ] , repr : & ReprOptions , kind| {
502
495
Ok ( tcx. intern_layout ( self . univariant_uninterned ( ty, fields, repr, kind) ?) )
@@ -505,11 +498,11 @@ impl<'tcx> LayoutCx<'tcx, TyCtxt<'tcx>> {
505
498
506
499
Ok ( match ty. kind {
507
500
// Basic scalars.
508
- ty:: Bool => tcx. intern_layout ( LayoutDetails :: scalar (
501
+ ty:: Bool => tcx. intern_layout ( Layout :: scalar (
509
502
self ,
510
503
Scalar { value : Int ( I8 , false ) , valid_range : 0 ..=1 } ,
511
504
) ) ,
512
- ty:: Char => tcx. intern_layout ( LayoutDetails :: scalar (
505
+ ty:: Char => tcx. intern_layout ( Layout :: scalar (
513
506
self ,
514
507
Scalar { value : Int ( I32 , false ) , valid_range : 0 ..=0x10FFFF } ,
515
508
) ) ,
@@ -522,11 +515,11 @@ impl<'tcx> LayoutCx<'tcx, TyCtxt<'tcx>> {
522
515
ty:: FnPtr ( _) => {
523
516
let mut ptr = scalar_unit ( Pointer ) ;
524
517
ptr. valid_range = 1 ..=* ptr. valid_range . end ( ) ;
525
- tcx. intern_layout ( LayoutDetails :: scalar ( self , ptr) )
518
+ tcx. intern_layout ( Layout :: scalar ( self , ptr) )
526
519
}
527
520
528
521
// The never type.
529
- ty:: Never => tcx. intern_layout ( LayoutDetails {
522
+ ty:: Never => tcx. intern_layout ( Layout {
530
523
variants : Variants :: Single { index : VariantIdx :: new ( 0 ) } ,
531
524
fields : FieldPlacement :: Union ( 0 ) ,
532
525
abi : Abi :: Uninhabited ,
@@ -544,13 +537,13 @@ impl<'tcx> LayoutCx<'tcx, TyCtxt<'tcx>> {
544
537
545
538
let pointee = tcx. normalize_erasing_regions ( param_env, pointee) ;
546
539
if pointee. is_sized ( tcx. at ( DUMMY_SP ) , param_env) {
547
- return Ok ( tcx. intern_layout ( LayoutDetails :: scalar ( self , data_ptr) ) ) ;
540
+ return Ok ( tcx. intern_layout ( Layout :: scalar ( self , data_ptr) ) ) ;
548
541
}
549
542
550
543
let unsized_part = tcx. struct_tail_erasing_lifetimes ( pointee, param_env) ;
551
544
let metadata = match unsized_part. kind {
552
545
ty:: Foreign ( ..) => {
553
- return Ok ( tcx. intern_layout ( LayoutDetails :: scalar ( self , data_ptr) ) ) ;
546
+ return Ok ( tcx. intern_layout ( Layout :: scalar ( self , data_ptr) ) ) ;
554
547
}
555
548
ty:: Slice ( _) | ty:: Str => scalar_unit ( Int ( dl. ptr_sized_integer ( ) , false ) ) ,
556
549
ty:: Dynamic ( ..) => {
@@ -587,7 +580,7 @@ impl<'tcx> LayoutCx<'tcx, TyCtxt<'tcx>> {
587
580
588
581
let largest_niche = if count != 0 { element. largest_niche . clone ( ) } else { None } ;
589
582
590
- tcx. intern_layout ( LayoutDetails {
583
+ tcx. intern_layout ( Layout {
591
584
variants : Variants :: Single { index : VariantIdx :: new ( 0 ) } ,
592
585
fields : FieldPlacement :: Array { stride : element. size , count } ,
593
586
abi,
@@ -598,7 +591,7 @@ impl<'tcx> LayoutCx<'tcx, TyCtxt<'tcx>> {
598
591
}
599
592
ty:: Slice ( element) => {
600
593
let element = self . layout_of ( element) ?;
601
- tcx. intern_layout ( LayoutDetails {
594
+ tcx. intern_layout ( Layout {
602
595
variants : Variants :: Single { index : VariantIdx :: new ( 0 ) } ,
603
596
fields : FieldPlacement :: Array { stride : element. size , count : 0 } ,
604
597
abi : Abi :: Aggregate { sized : false } ,
@@ -607,7 +600,7 @@ impl<'tcx> LayoutCx<'tcx, TyCtxt<'tcx>> {
607
600
size : Size :: ZERO ,
608
601
} )
609
602
}
610
- ty:: Str => tcx. intern_layout ( LayoutDetails {
603
+ ty:: Str => tcx. intern_layout ( Layout {
611
604
variants : Variants :: Single { index : VariantIdx :: new ( 0 ) } ,
612
605
fields : FieldPlacement :: Array { stride : Size :: from_bytes ( 1 ) , count : 0 } ,
613
606
abi : Abi :: Aggregate { sized : false } ,
@@ -676,7 +669,7 @@ impl<'tcx> LayoutCx<'tcx, TyCtxt<'tcx>> {
676
669
let align = dl. vector_align ( size) ;
677
670
let size = size. align_to ( align. abi ) ;
678
671
679
- tcx. intern_layout ( LayoutDetails {
672
+ tcx. intern_layout ( Layout {
680
673
variants : Variants :: Single { index : VariantIdx :: new ( 0 ) } ,
681
674
fields : FieldPlacement :: Array { stride : element. size , count } ,
682
675
abi : Abi :: Vector { element : scalar, count } ,
@@ -752,7 +745,7 @@ impl<'tcx> LayoutCx<'tcx, TyCtxt<'tcx>> {
752
745
align = align. min ( AbiAndPrefAlign :: new ( pack) ) ;
753
746
}
754
747
755
- return Ok ( tcx. intern_layout ( LayoutDetails {
748
+ return Ok ( tcx. intern_layout ( Layout {
756
749
variants : Variants :: Single { index } ,
757
750
fields : FieldPlacement :: Union ( variants[ index] . len ( ) ) ,
758
751
abi,
@@ -976,7 +969,7 @@ impl<'tcx> LayoutCx<'tcx, TyCtxt<'tcx>> {
976
969
let largest_niche =
977
970
Niche :: from_scalar ( dl, offset, niche_scalar. clone ( ) ) ;
978
971
979
- return Ok ( tcx. intern_layout ( LayoutDetails {
972
+ return Ok ( tcx. intern_layout ( Layout {
980
973
variants : Variants :: Multiple {
981
974
discr : niche_scalar,
982
975
discr_kind : DiscriminantKind :: Niche {
@@ -1171,7 +1164,7 @@ impl<'tcx> LayoutCx<'tcx, TyCtxt<'tcx>> {
1171
1164
break ;
1172
1165
}
1173
1166
} ;
1174
- let prim = match field. details . abi {
1167
+ let prim = match field. abi {
1175
1168
Abi :: Scalar ( ref scalar) => scalar. value ,
1176
1169
_ => {
1177
1170
common_prim = None ;
@@ -1218,7 +1211,7 @@ impl<'tcx> LayoutCx<'tcx, TyCtxt<'tcx>> {
1218
1211
1219
1212
let largest_niche = Niche :: from_scalar ( dl, Size :: ZERO , tag. clone ( ) ) ;
1220
1213
1221
- tcx. intern_layout ( LayoutDetails {
1214
+ tcx. intern_layout ( Layout {
1222
1215
variants : Variants :: Multiple {
1223
1216
discr : tag,
1224
1217
discr_kind : DiscriminantKind :: Tag ,
@@ -1249,7 +1242,7 @@ impl<'tcx> LayoutCx<'tcx, TyCtxt<'tcx>> {
1249
1242
| ty:: Placeholder ( ..)
1250
1243
| ty:: UnnormalizedProjection ( ..)
1251
1244
| ty:: GeneratorWitness ( ..)
1252
- | ty:: Infer ( _) => bug ! ( "LayoutDetails ::compute: unexpected type `{}`" , ty) ,
1245
+ | ty:: Infer ( _) => bug ! ( "Layout ::compute: unexpected type `{}`" , ty) ,
1253
1246
1254
1247
ty:: Param ( _) | ty:: Error => {
1255
1248
return Err ( LayoutError :: Unknown ( ty) ) ;
@@ -1396,7 +1389,7 @@ impl<'tcx> LayoutCx<'tcx, TyCtxt<'tcx>> {
1396
1389
ty : Ty < ' tcx > ,
1397
1390
def_id : hir:: def_id:: DefId ,
1398
1391
substs : SubstsRef < ' tcx > ,
1399
- ) -> Result < & ' tcx LayoutDetails , LayoutError < ' tcx > > {
1392
+ ) -> Result < & ' tcx Layout , LayoutError < ' tcx > > {
1400
1393
use SavedLocalEligibility :: * ;
1401
1394
let tcx = self . tcx ;
1402
1395
@@ -1562,7 +1555,7 @@ impl<'tcx> LayoutCx<'tcx, TyCtxt<'tcx>> {
1562
1555
Abi :: Aggregate { sized : true }
1563
1556
} ;
1564
1557
1565
- let layout = tcx. intern_layout ( LayoutDetails {
1558
+ let layout = tcx. intern_layout ( Layout {
1566
1559
variants : Variants :: Multiple {
1567
1560
discr,
1568
1561
discr_kind : DiscriminantKind :: Tag ,
@@ -1945,8 +1938,8 @@ impl<'tcx> LayoutOf for LayoutCx<'tcx, TyCtxt<'tcx>> {
1945
1938
fn layout_of ( & self , ty : Ty < ' tcx > ) -> Self :: TyLayout {
1946
1939
let param_env = self . param_env . with_reveal_all ( ) ;
1947
1940
let ty = self . tcx . normalize_erasing_regions ( param_env, ty) ;
1948
- let details = self . tcx . layout_raw ( param_env. and ( ty) ) ?;
1949
- let layout = TyLayout { ty, details } ;
1941
+ let layout = self . tcx . layout_raw ( param_env. and ( ty) ) ?;
1942
+ let layout = TyLayout { ty, layout } ;
1950
1943
1951
1944
// N.B., this recording is normally disabled; when enabled, it
1952
1945
// can however trigger recursive invocations of `layout_of`.
@@ -1969,8 +1962,8 @@ impl LayoutOf for LayoutCx<'tcx, ty::query::TyCtxtAt<'tcx>> {
1969
1962
fn layout_of ( & self , ty : Ty < ' tcx > ) -> Self :: TyLayout {
1970
1963
let param_env = self . param_env . with_reveal_all ( ) ;
1971
1964
let ty = self . tcx . normalize_erasing_regions ( param_env, ty) ;
1972
- let details = self . tcx . layout_raw ( param_env. and ( ty) ) ?;
1973
- let layout = TyLayout { ty, details } ;
1965
+ let layout = self . tcx . layout_raw ( param_env. and ( ty) ) ?;
1966
+ let layout = TyLayout { ty, layout } ;
1974
1967
1975
1968
// N.B., this recording is normally disabled; when enabled, it
1976
1969
// can however trigger recursive invocations of `layout_of`.
@@ -2019,21 +2012,21 @@ where
2019
2012
+ HasParamEnv < ' tcx > ,
2020
2013
{
2021
2014
fn for_variant ( this : TyLayout < ' tcx > , cx : & C , variant_index : VariantIdx ) -> TyLayout < ' tcx > {
2022
- let details = match this. variants {
2023
- Variants :: Single { index } if index == variant_index => this. details ,
2015
+ let layout = match this. variants {
2016
+ Variants :: Single { index } if index == variant_index => this. layout ,
2024
2017
2025
2018
Variants :: Single { index } => {
2026
2019
// Deny calling for_variant more than once for non-Single enums.
2027
- if let Ok ( layout ) = cx. layout_of ( this. ty ) . to_result ( ) {
2028
- assert_eq ! ( layout . variants, Variants :: Single { index } ) ;
2020
+ if let Ok ( original_layout ) = cx. layout_of ( this. ty ) . to_result ( ) {
2021
+ assert_eq ! ( original_layout . variants, Variants :: Single { index } ) ;
2029
2022
}
2030
2023
2031
2024
let fields = match this. ty . kind {
2032
2025
ty:: Adt ( def, _) => def. variants [ variant_index] . fields . len ( ) ,
2033
2026
_ => bug ! ( ) ,
2034
2027
} ;
2035
2028
let tcx = cx. tcx ( ) ;
2036
- tcx. intern_layout ( LayoutDetails {
2029
+ tcx. intern_layout ( Layout {
2037
2030
variants : Variants :: Single { index : variant_index } ,
2038
2031
fields : FieldPlacement :: Union ( fields) ,
2039
2032
abi : Abi :: Uninhabited ,
@@ -2046,17 +2039,17 @@ where
2046
2039
Variants :: Multiple { ref variants, .. } => & variants[ variant_index] ,
2047
2040
} ;
2048
2041
2049
- assert_eq ! ( details . variants, Variants :: Single { index: variant_index } ) ;
2042
+ assert_eq ! ( layout . variants, Variants :: Single { index: variant_index } ) ;
2050
2043
2051
- TyLayout { ty : this. ty , details }
2044
+ TyLayout { ty : this. ty , layout }
2052
2045
}
2053
2046
2054
2047
fn field ( this : TyLayout < ' tcx > , cx : & C , i : usize ) -> C :: TyLayout {
2055
2048
let tcx = cx. tcx ( ) ;
2056
2049
let discr_layout = |discr : & Scalar | -> C :: TyLayout {
2057
- let layout = LayoutDetails :: scalar ( cx, discr. clone ( ) ) ;
2050
+ let layout = Layout :: scalar ( cx, discr. clone ( ) ) ;
2058
2051
MaybeResult :: from ( Ok ( TyLayout {
2059
- details : tcx. intern_layout ( layout) ,
2052
+ layout : tcx. intern_layout ( layout) ,
2060
2053
ty : discr. value . to_ty ( tcx) ,
2061
2054
} ) )
2062
2055
} ;
0 commit comments