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