@@ -181,7 +181,7 @@ impl<'tcx> fmt::Display for LayoutError<'tcx> {
181
181
fn layout_raw < ' tcx > (
182
182
tcx : TyCtxt < ' tcx > ,
183
183
query : ty:: ParamEnvAnd < ' tcx , Ty < ' tcx > > ,
184
- ) -> Result < & ' tcx LayoutDetails , LayoutError < ' tcx > > {
184
+ ) -> Result < & ' tcx Layout , LayoutError < ' tcx > > {
185
185
ty:: tls:: with_related_context ( tcx, move |icx| {
186
186
let rec_limit = * tcx. sess . recursion_limit . get ( ) ;
187
187
let ( param_env, ty) = query. into_parts ( ) ;
@@ -240,7 +240,7 @@ fn invert_mapping(map: &[u32]) -> Vec<u32> {
240
240
}
241
241
242
242
impl < ' tcx > LayoutCx < ' tcx , TyCtxt < ' tcx > > {
243
- fn scalar_pair ( & self , a : Scalar , b : Scalar ) -> LayoutDetails {
243
+ fn scalar_pair ( & self , a : Scalar , b : Scalar ) -> Layout {
244
244
let dl = self . data_layout ( ) ;
245
245
let b_align = b. value . align ( dl) ;
246
246
let align = a. value . align ( dl) . max ( b_align) . max ( dl. aggregate_align ) ;
@@ -254,7 +254,7 @@ impl<'tcx> LayoutCx<'tcx, TyCtxt<'tcx>> {
254
254
. chain ( Niche :: from_scalar ( dl, Size :: ZERO , a. clone ( ) ) )
255
255
. max_by_key ( |niche| niche. available ( dl) ) ;
256
256
257
- LayoutDetails {
257
+ Layout {
258
258
variants : Variants :: Single { index : VariantIdx :: new ( 0 ) } ,
259
259
fields : FieldPlacement :: Arbitrary {
260
260
offsets : vec ! [ Size :: ZERO , b_offset] ,
@@ -273,7 +273,7 @@ impl<'tcx> LayoutCx<'tcx, TyCtxt<'tcx>> {
273
273
fields : & [ TyLayout < ' _ > ] ,
274
274
repr : & ReprOptions ,
275
275
kind : StructKind ,
276
- ) -> Result < LayoutDetails , LayoutError < ' tcx > > {
276
+ ) -> Result < Layout , LayoutError < ' tcx > > {
277
277
let dl = self . data_layout ( ) ;
278
278
let pack = repr. pack ;
279
279
if pack. is_some ( ) && repr. align . is_some ( ) {
@@ -422,17 +422,11 @@ impl<'tcx> LayoutCx<'tcx, TyCtxt<'tcx>> {
422
422
(
423
423
Some ( (
424
424
i,
425
- & TyLayout {
426
- details : & LayoutDetails { abi : Abi :: Scalar ( ref a) , .. } ,
427
- ..
428
- } ,
425
+ & TyLayout { layout : & Layout { abi : Abi :: Scalar ( ref a) , .. } , .. } ,
429
426
) ) ,
430
427
Some ( (
431
428
j,
432
- & TyLayout {
433
- details : & LayoutDetails { abi : Abi :: Scalar ( ref b) , .. } ,
434
- ..
435
- } ,
429
+ & TyLayout { layout : & Layout { abi : Abi :: Scalar ( ref b) , .. } , .. } ,
436
430
) ) ,
437
431
None ,
438
432
) => {
@@ -470,7 +464,7 @@ impl<'tcx> LayoutCx<'tcx, TyCtxt<'tcx>> {
470
464
abi = Abi :: Uninhabited ;
471
465
}
472
466
473
- Ok ( LayoutDetails {
467
+ Ok ( Layout {
474
468
variants : Variants :: Single { index : VariantIdx :: new ( 0 ) } ,
475
469
fields : FieldPlacement :: Arbitrary { offsets, memory_index } ,
476
470
abi,
@@ -480,7 +474,7 @@ impl<'tcx> LayoutCx<'tcx, TyCtxt<'tcx>> {
480
474
} )
481
475
}
482
476
483
- fn layout_raw_uncached ( & self , ty : Ty < ' tcx > ) -> Result < & ' tcx LayoutDetails , LayoutError < ' tcx > > {
477
+ fn layout_raw_uncached ( & self , ty : Ty < ' tcx > ) -> Result < & ' tcx Layout , LayoutError < ' tcx > > {
484
478
let tcx = self . tcx ;
485
479
let param_env = self . param_env ;
486
480
let dl = self . data_layout ( ) ;
@@ -489,8 +483,7 @@ impl<'tcx> LayoutCx<'tcx, TyCtxt<'tcx>> {
489
483
assert ! ( bits <= 128 ) ;
490
484
Scalar { value, valid_range : 0 ..=( !0 >> ( 128 - bits) ) }
491
485
} ;
492
- let scalar =
493
- |value : Primitive | tcx. intern_layout ( LayoutDetails :: scalar ( self , scalar_unit ( value) ) ) ;
486
+ let scalar = |value : Primitive | tcx. intern_layout ( Layout :: scalar ( self , scalar_unit ( value) ) ) ;
494
487
495
488
let univariant = |fields : & [ TyLayout < ' _ > ] , repr : & ReprOptions , kind| {
496
489
Ok ( tcx. intern_layout ( self . univariant_uninterned ( ty, fields, repr, kind) ?) )
@@ -499,11 +492,11 @@ impl<'tcx> LayoutCx<'tcx, TyCtxt<'tcx>> {
499
492
500
493
Ok ( match ty. kind {
501
494
// Basic scalars.
502
- ty:: Bool => tcx. intern_layout ( LayoutDetails :: scalar (
495
+ ty:: Bool => tcx. intern_layout ( Layout :: scalar (
503
496
self ,
504
497
Scalar { value : Int ( I8 , false ) , valid_range : 0 ..=1 } ,
505
498
) ) ,
506
- ty:: Char => tcx. intern_layout ( LayoutDetails :: scalar (
499
+ ty:: Char => tcx. intern_layout ( Layout :: scalar (
507
500
self ,
508
501
Scalar { value : Int ( I32 , false ) , valid_range : 0 ..=0x10FFFF } ,
509
502
) ) ,
@@ -516,11 +509,11 @@ impl<'tcx> LayoutCx<'tcx, TyCtxt<'tcx>> {
516
509
ty:: FnPtr ( _) => {
517
510
let mut ptr = scalar_unit ( Pointer ) ;
518
511
ptr. valid_range = 1 ..=* ptr. valid_range . end ( ) ;
519
- tcx. intern_layout ( LayoutDetails :: scalar ( self , ptr) )
512
+ tcx. intern_layout ( Layout :: scalar ( self , ptr) )
520
513
}
521
514
522
515
// The never type.
523
- ty:: Never => tcx. intern_layout ( LayoutDetails {
516
+ ty:: Never => tcx. intern_layout ( Layout {
524
517
variants : Variants :: Single { index : VariantIdx :: new ( 0 ) } ,
525
518
fields : FieldPlacement :: Union ( 0 ) ,
526
519
abi : Abi :: Uninhabited ,
@@ -538,13 +531,13 @@ impl<'tcx> LayoutCx<'tcx, TyCtxt<'tcx>> {
538
531
539
532
let pointee = tcx. normalize_erasing_regions ( param_env, pointee) ;
540
533
if pointee. is_sized ( tcx. at ( DUMMY_SP ) , param_env) {
541
- return Ok ( tcx. intern_layout ( LayoutDetails :: scalar ( self , data_ptr) ) ) ;
534
+ return Ok ( tcx. intern_layout ( Layout :: scalar ( self , data_ptr) ) ) ;
542
535
}
543
536
544
537
let unsized_part = tcx. struct_tail_erasing_lifetimes ( pointee, param_env) ;
545
538
let metadata = match unsized_part. kind {
546
539
ty:: Foreign ( ..) => {
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
ty:: Slice ( _) | ty:: Str => scalar_unit ( Int ( dl. ptr_sized_integer ( ) , false ) ) ,
550
543
ty:: Dynamic ( ..) => {
@@ -581,7 +574,7 @@ impl<'tcx> LayoutCx<'tcx, TyCtxt<'tcx>> {
581
574
582
575
let largest_niche = if count != 0 { element. largest_niche . clone ( ) } else { None } ;
583
576
584
- tcx. intern_layout ( LayoutDetails {
577
+ tcx. intern_layout ( Layout {
585
578
variants : Variants :: Single { index : VariantIdx :: new ( 0 ) } ,
586
579
fields : FieldPlacement :: Array { stride : element. size , count } ,
587
580
abi,
@@ -592,7 +585,7 @@ impl<'tcx> LayoutCx<'tcx, TyCtxt<'tcx>> {
592
585
}
593
586
ty:: Slice ( element) => {
594
587
let element = self . layout_of ( element) ?;
595
- tcx. intern_layout ( LayoutDetails {
588
+ tcx. intern_layout ( Layout {
596
589
variants : Variants :: Single { index : VariantIdx :: new ( 0 ) } ,
597
590
fields : FieldPlacement :: Array { stride : element. size , count : 0 } ,
598
591
abi : Abi :: Aggregate { sized : false } ,
@@ -601,7 +594,7 @@ impl<'tcx> LayoutCx<'tcx, TyCtxt<'tcx>> {
601
594
size : Size :: ZERO ,
602
595
} )
603
596
}
604
- ty:: Str => tcx. intern_layout ( LayoutDetails {
597
+ ty:: Str => tcx. intern_layout ( Layout {
605
598
variants : Variants :: Single { index : VariantIdx :: new ( 0 ) } ,
606
599
fields : FieldPlacement :: Array { stride : Size :: from_bytes ( 1 ) , count : 0 } ,
607
600
abi : Abi :: Aggregate { sized : false } ,
@@ -670,7 +663,7 @@ impl<'tcx> LayoutCx<'tcx, TyCtxt<'tcx>> {
670
663
let align = dl. vector_align ( size) ;
671
664
let size = size. align_to ( align. abi ) ;
672
665
673
- tcx. intern_layout ( LayoutDetails {
666
+ tcx. intern_layout ( Layout {
674
667
variants : Variants :: Single { index : VariantIdx :: new ( 0 ) } ,
675
668
fields : FieldPlacement :: Array { stride : element. size , count } ,
676
669
abi : Abi :: Vector { element : scalar, count } ,
@@ -746,7 +739,7 @@ impl<'tcx> LayoutCx<'tcx, TyCtxt<'tcx>> {
746
739
align = align. min ( AbiAndPrefAlign :: new ( pack) ) ;
747
740
}
748
741
749
- return Ok ( tcx. intern_layout ( LayoutDetails {
742
+ return Ok ( tcx. intern_layout ( Layout {
750
743
variants : Variants :: Single { index } ,
751
744
fields : FieldPlacement :: Union ( variants[ index] . len ( ) ) ,
752
745
abi,
@@ -970,7 +963,7 @@ impl<'tcx> LayoutCx<'tcx, TyCtxt<'tcx>> {
970
963
let largest_niche =
971
964
Niche :: from_scalar ( dl, offset, niche_scalar. clone ( ) ) ;
972
965
973
- return Ok ( tcx. intern_layout ( LayoutDetails {
966
+ return Ok ( tcx. intern_layout ( Layout {
974
967
variants : Variants :: Multiple {
975
968
discr : niche_scalar,
976
969
discr_kind : DiscriminantKind :: Niche {
@@ -1165,7 +1158,7 @@ impl<'tcx> LayoutCx<'tcx, TyCtxt<'tcx>> {
1165
1158
break ;
1166
1159
}
1167
1160
} ;
1168
- let prim = match field. details . abi {
1161
+ let prim = match field. abi {
1169
1162
Abi :: Scalar ( ref scalar) => scalar. value ,
1170
1163
_ => {
1171
1164
common_prim = None ;
@@ -1212,7 +1205,7 @@ impl<'tcx> LayoutCx<'tcx, TyCtxt<'tcx>> {
1212
1205
1213
1206
let largest_niche = Niche :: from_scalar ( dl, Size :: ZERO , tag. clone ( ) ) ;
1214
1207
1215
- tcx. intern_layout ( LayoutDetails {
1208
+ tcx. intern_layout ( Layout {
1216
1209
variants : Variants :: Multiple {
1217
1210
discr : tag,
1218
1211
discr_kind : DiscriminantKind :: Tag ,
@@ -1243,7 +1236,7 @@ impl<'tcx> LayoutCx<'tcx, TyCtxt<'tcx>> {
1243
1236
| ty:: Placeholder ( ..)
1244
1237
| ty:: UnnormalizedProjection ( ..)
1245
1238
| ty:: GeneratorWitness ( ..)
1246
- | ty:: Infer ( _) => bug ! ( "LayoutDetails ::compute: unexpected type `{}`" , ty) ,
1239
+ | ty:: Infer ( _) => bug ! ( "Layout ::compute: unexpected type `{}`" , ty) ,
1247
1240
1248
1241
ty:: Param ( _) | ty:: Error => {
1249
1242
return Err ( LayoutError :: Unknown ( ty) ) ;
@@ -1390,7 +1383,7 @@ impl<'tcx> LayoutCx<'tcx, TyCtxt<'tcx>> {
1390
1383
ty : Ty < ' tcx > ,
1391
1384
def_id : hir:: def_id:: DefId ,
1392
1385
substs : SubstsRef < ' tcx > ,
1393
- ) -> Result < & ' tcx LayoutDetails , LayoutError < ' tcx > > {
1386
+ ) -> Result < & ' tcx Layout , LayoutError < ' tcx > > {
1394
1387
use SavedLocalEligibility :: * ;
1395
1388
let tcx = self . tcx ;
1396
1389
@@ -1409,8 +1402,8 @@ impl<'tcx> LayoutCx<'tcx, TyCtxt<'tcx>> {
1409
1402
let discr_int = Integer :: fit_unsigned ( max_discr) ;
1410
1403
let discr_int_ty = discr_int. to_ty ( tcx, false ) ;
1411
1404
let discr = Scalar { value : Primitive :: Int ( discr_int, false ) , valid_range : 0 ..=max_discr } ;
1412
- let discr_layout = self . tcx . intern_layout ( LayoutDetails :: scalar ( self , discr. clone ( ) ) ) ;
1413
- let discr_layout = TyLayout { ty : discr_int_ty, details : discr_layout } ;
1405
+ let discr_layout = self . tcx . intern_layout ( Layout :: scalar ( self , discr. clone ( ) ) ) ;
1406
+ let discr_layout = TyLayout { ty : discr_int_ty, layout : discr_layout } ;
1414
1407
1415
1408
let promoted_layouts = ineligible_locals
1416
1409
. iter ( )
@@ -1559,7 +1552,7 @@ impl<'tcx> LayoutCx<'tcx, TyCtxt<'tcx>> {
1559
1552
Abi :: Aggregate { sized : true }
1560
1553
} ;
1561
1554
1562
- let layout = tcx. intern_layout ( LayoutDetails {
1555
+ let layout = tcx. intern_layout ( Layout {
1563
1556
variants : Variants :: Multiple {
1564
1557
discr,
1565
1558
discr_kind : DiscriminantKind :: Tag ,
@@ -1908,8 +1901,8 @@ impl<'tcx> LayoutOf for LayoutCx<'tcx, TyCtxt<'tcx>> {
1908
1901
fn layout_of ( & self , ty : Ty < ' tcx > ) -> Self :: TyLayout {
1909
1902
let param_env = self . param_env . with_reveal_all ( ) ;
1910
1903
let ty = self . tcx . normalize_erasing_regions ( param_env, ty) ;
1911
- let details = self . tcx . layout_raw ( param_env. and ( ty) ) ?;
1912
- let layout = TyLayout { ty, details } ;
1904
+ let layout = self . tcx . layout_raw ( param_env. and ( ty) ) ?;
1905
+ let layout = TyLayout { ty, layout } ;
1913
1906
1914
1907
// N.B., this recording is normally disabled; when enabled, it
1915
1908
// can however trigger recursive invocations of `layout_of`.
@@ -1932,8 +1925,8 @@ impl LayoutOf for LayoutCx<'tcx, ty::query::TyCtxtAt<'tcx>> {
1932
1925
fn layout_of ( & self , ty : Ty < ' tcx > ) -> Self :: TyLayout {
1933
1926
let param_env = self . param_env . with_reveal_all ( ) ;
1934
1927
let ty = self . tcx . normalize_erasing_regions ( param_env, ty) ;
1935
- let details = self . tcx . layout_raw ( param_env. and ( ty) ) ?;
1936
- let layout = TyLayout { ty, details } ;
1928
+ let layout = self . tcx . layout_raw ( param_env. and ( ty) ) ?;
1929
+ let layout = TyLayout { ty, layout } ;
1937
1930
1938
1931
// N.B., this recording is normally disabled; when enabled, it
1939
1932
// can however trigger recursive invocations of `layout_of`.
@@ -1982,29 +1975,29 @@ where
1982
1975
+ HasParamEnv < ' tcx > ,
1983
1976
{
1984
1977
fn for_variant ( this : TyLayout < ' tcx > , cx : & C , variant_index : VariantIdx ) -> TyLayout < ' tcx > {
1985
- let details = match this. variants {
1978
+ let layout = match this. variants {
1986
1979
Variants :: Single { index }
1987
1980
// If all variants but one are uninhabited, the variant layout is the enum layout.
1988
1981
if index == variant_index &&
1989
1982
// Don't confuse variants of uninhabited enums with the enum itself.
1990
1983
// For more details see https://github.com/rust-lang/rust/issues/69763.
1991
1984
this. fields != FieldPlacement :: Union ( 0 ) =>
1992
1985
{
1993
- this. details
1986
+ this. layout
1994
1987
}
1995
1988
1996
1989
Variants :: Single { index } => {
1997
1990
// Deny calling for_variant more than once for non-Single enums.
1998
- if let Ok ( layout ) = cx. layout_of ( this. ty ) . to_result ( ) {
1999
- assert_eq ! ( layout . variants, Variants :: Single { index } ) ;
1991
+ if let Ok ( original_layout ) = cx. layout_of ( this. ty ) . to_result ( ) {
1992
+ assert_eq ! ( original_layout . variants, Variants :: Single { index } ) ;
2000
1993
}
2001
1994
2002
1995
let fields = match this. ty . kind {
2003
1996
ty:: Adt ( def, _) => def. variants [ variant_index] . fields . len ( ) ,
2004
1997
_ => bug ! ( ) ,
2005
1998
} ;
2006
1999
let tcx = cx. tcx ( ) ;
2007
- tcx. intern_layout ( LayoutDetails {
2000
+ tcx. intern_layout ( Layout {
2008
2001
variants : Variants :: Single { index : variant_index } ,
2009
2002
fields : FieldPlacement :: Union ( fields) ,
2010
2003
abi : Abi :: Uninhabited ,
@@ -2017,17 +2010,17 @@ where
2017
2010
Variants :: Multiple { ref variants, .. } => & variants[ variant_index] ,
2018
2011
} ;
2019
2012
2020
- assert_eq ! ( details . variants, Variants :: Single { index: variant_index } ) ;
2013
+ assert_eq ! ( layout . variants, Variants :: Single { index: variant_index } ) ;
2021
2014
2022
- TyLayout { ty : this. ty , details }
2015
+ TyLayout { ty : this. ty , layout }
2023
2016
}
2024
2017
2025
2018
fn field ( this : TyLayout < ' tcx > , cx : & C , i : usize ) -> C :: TyLayout {
2026
2019
let tcx = cx. tcx ( ) ;
2027
2020
let discr_layout = |discr : & Scalar | -> C :: TyLayout {
2028
- let layout = LayoutDetails :: scalar ( cx, discr. clone ( ) ) ;
2021
+ let layout = Layout :: scalar ( cx, discr. clone ( ) ) ;
2029
2022
MaybeResult :: from ( Ok ( TyLayout {
2030
- details : tcx. intern_layout ( layout) ,
2023
+ layout : tcx. intern_layout ( layout) ,
2031
2024
ty : discr. value . to_ty ( tcx) ,
2032
2025
} ) )
2033
2026
} ;
0 commit comments