@@ -184,7 +184,7 @@ impl<'tcx> fmt::Display for LayoutError<'tcx> {
184184fn layout_raw < ' tcx > (
185185 tcx : TyCtxt < ' tcx > ,
186186 query : ty:: ParamEnvAnd < ' tcx , Ty < ' tcx > > ,
187- ) -> Result < & ' tcx LayoutDetails , LayoutError < ' tcx > > {
187+ ) -> Result < & ' tcx Layout , LayoutError < ' tcx > > {
188188 ty:: tls:: with_related_context ( tcx, move |icx| {
189189 let rec_limit = * tcx. sess . recursion_limit . get ( ) ;
190190 let ( param_env, ty) = query. into_parts ( ) ;
@@ -243,7 +243,7 @@ fn invert_mapping(map: &[u32]) -> Vec<u32> {
243243}
244244
245245impl < ' 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 {
247247 let dl = self . data_layout ( ) ;
248248 let b_align = b. value . align ( dl) ;
249249 let align = a. value . align ( dl) . max ( b_align) . max ( dl. aggregate_align ) ;
@@ -257,7 +257,7 @@ impl<'tcx> LayoutCx<'tcx, TyCtxt<'tcx>> {
257257 . chain ( Niche :: from_scalar ( dl, Size :: ZERO , a. clone ( ) ) )
258258 . max_by_key ( |niche| niche. available ( dl) ) ;
259259
260- LayoutDetails {
260+ Layout {
261261 variants : Variants :: Single { index : VariantIdx :: new ( 0 ) } ,
262262 fields : FieldPlacement :: Arbitrary {
263263 offsets : vec ! [ Size :: ZERO , b_offset] ,
@@ -276,7 +276,7 @@ impl<'tcx> LayoutCx<'tcx, TyCtxt<'tcx>> {
276276 fields : & [ TyLayout < ' _ > ] ,
277277 repr : & ReprOptions ,
278278 kind : StructKind ,
279- ) -> Result < LayoutDetails , LayoutError < ' tcx > > {
279+ ) -> Result < Layout , LayoutError < ' tcx > > {
280280 let dl = self . data_layout ( ) ;
281281 let pack = repr. pack ;
282282 if pack. is_some ( ) && repr. align . is_some ( ) {
@@ -429,17 +429,11 @@ impl<'tcx> LayoutCx<'tcx, TyCtxt<'tcx>> {
429429 (
430430 Some ( (
431431 i,
432- & TyLayout {
433- details : & LayoutDetails { abi : Abi :: Scalar ( ref a) , .. } ,
434- ..
435- } ,
432+ & TyLayout { layout : & Layout { abi : Abi :: Scalar ( ref a) , .. } , .. } ,
436433 ) ) ,
437434 Some ( (
438435 j,
439- & TyLayout {
440- details : & LayoutDetails { abi : Abi :: Scalar ( ref b) , .. } ,
441- ..
442- } ,
436+ & TyLayout { layout : & Layout { abi : Abi :: Scalar ( ref b) , .. } , .. } ,
443437 ) ) ,
444438 None ,
445439 ) => {
@@ -477,7 +471,7 @@ impl<'tcx> LayoutCx<'tcx, TyCtxt<'tcx>> {
477471 abi = Abi :: Uninhabited ;
478472 }
479473
480- Ok ( LayoutDetails {
474+ Ok ( Layout {
481475 variants : Variants :: Single { index : VariantIdx :: new ( 0 ) } ,
482476 fields : FieldPlacement :: Arbitrary { offsets, memory_index } ,
483477 abi,
@@ -487,7 +481,7 @@ impl<'tcx> LayoutCx<'tcx, TyCtxt<'tcx>> {
487481 } )
488482 }
489483
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 > > {
491485 let tcx = self . tcx ;
492486 let param_env = self . param_env ;
493487 let dl = self . data_layout ( ) ;
@@ -496,8 +490,7 @@ impl<'tcx> LayoutCx<'tcx, TyCtxt<'tcx>> {
496490 assert ! ( bits <= 128 ) ;
497491 Scalar { value, valid_range : 0 ..=( !0 >> ( 128 - bits) ) }
498492 } ;
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) ) ) ;
501494
502495 let univariant = |fields : & [ TyLayout < ' _ > ] , repr : & ReprOptions , kind| {
503496 Ok ( tcx. intern_layout ( self . univariant_uninterned ( ty, fields, repr, kind) ?) )
@@ -506,11 +499,11 @@ impl<'tcx> LayoutCx<'tcx, TyCtxt<'tcx>> {
506499
507500 Ok ( match ty. kind {
508501 // Basic scalars.
509- ty:: Bool => tcx. intern_layout ( LayoutDetails :: scalar (
502+ ty:: Bool => tcx. intern_layout ( Layout :: scalar (
510503 self ,
511504 Scalar { value : Int ( I8 , false ) , valid_range : 0 ..=1 } ,
512505 ) ) ,
513- ty:: Char => tcx. intern_layout ( LayoutDetails :: scalar (
506+ ty:: Char => tcx. intern_layout ( Layout :: scalar (
514507 self ,
515508 Scalar { value : Int ( I32 , false ) , valid_range : 0 ..=0x10FFFF } ,
516509 ) ) ,
@@ -523,11 +516,11 @@ impl<'tcx> LayoutCx<'tcx, TyCtxt<'tcx>> {
523516 ty:: FnPtr ( _) => {
524517 let mut ptr = scalar_unit ( Pointer ) ;
525518 ptr. valid_range = 1 ..=* ptr. valid_range . end ( ) ;
526- tcx. intern_layout ( LayoutDetails :: scalar ( self , ptr) )
519+ tcx. intern_layout ( Layout :: scalar ( self , ptr) )
527520 }
528521
529522 // The never type.
530- ty:: Never => tcx. intern_layout ( LayoutDetails {
523+ ty:: Never => tcx. intern_layout ( Layout {
531524 variants : Variants :: Single { index : VariantIdx :: new ( 0 ) } ,
532525 fields : FieldPlacement :: Union ( 0 ) ,
533526 abi : Abi :: Uninhabited ,
@@ -545,13 +538,13 @@ impl<'tcx> LayoutCx<'tcx, TyCtxt<'tcx>> {
545538
546539 let pointee = tcx. normalize_erasing_regions ( param_env, pointee) ;
547540 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) ) ) ;
549542 }
550543
551544 let unsized_part = tcx. struct_tail_erasing_lifetimes ( pointee, param_env) ;
552545 let metadata = match unsized_part. kind {
553546 ty:: Foreign ( ..) => {
554- return Ok ( tcx. intern_layout ( LayoutDetails :: scalar ( self , data_ptr) ) ) ;
547+ return Ok ( tcx. intern_layout ( Layout :: scalar ( self , data_ptr) ) ) ;
555548 }
556549 ty:: Slice ( _) | ty:: Str => scalar_unit ( Int ( dl. ptr_sized_integer ( ) , false ) ) ,
557550 ty:: Dynamic ( ..) => {
@@ -588,7 +581,7 @@ impl<'tcx> LayoutCx<'tcx, TyCtxt<'tcx>> {
588581
589582 let largest_niche = if count != 0 { element. largest_niche . clone ( ) } else { None } ;
590583
591- tcx. intern_layout ( LayoutDetails {
584+ tcx. intern_layout ( Layout {
592585 variants : Variants :: Single { index : VariantIdx :: new ( 0 ) } ,
593586 fields : FieldPlacement :: Array { stride : element. size , count } ,
594587 abi,
@@ -599,7 +592,7 @@ impl<'tcx> LayoutCx<'tcx, TyCtxt<'tcx>> {
599592 }
600593 ty:: Slice ( element) => {
601594 let element = self . layout_of ( element) ?;
602- tcx. intern_layout ( LayoutDetails {
595+ tcx. intern_layout ( Layout {
603596 variants : Variants :: Single { index : VariantIdx :: new ( 0 ) } ,
604597 fields : FieldPlacement :: Array { stride : element. size , count : 0 } ,
605598 abi : Abi :: Aggregate { sized : false } ,
@@ -608,7 +601,7 @@ impl<'tcx> LayoutCx<'tcx, TyCtxt<'tcx>> {
608601 size : Size :: ZERO ,
609602 } )
610603 }
611- ty:: Str => tcx. intern_layout ( LayoutDetails {
604+ ty:: Str => tcx. intern_layout ( Layout {
612605 variants : Variants :: Single { index : VariantIdx :: new ( 0 ) } ,
613606 fields : FieldPlacement :: Array { stride : Size :: from_bytes ( 1 ) , count : 0 } ,
614607 abi : Abi :: Aggregate { sized : false } ,
@@ -677,7 +670,7 @@ impl<'tcx> LayoutCx<'tcx, TyCtxt<'tcx>> {
677670 let align = dl. vector_align ( size) ;
678671 let size = size. align_to ( align. abi ) ;
679672
680- tcx. intern_layout ( LayoutDetails {
673+ tcx. intern_layout ( Layout {
681674 variants : Variants :: Single { index : VariantIdx :: new ( 0 ) } ,
682675 fields : FieldPlacement :: Array { stride : element. size , count } ,
683676 abi : Abi :: Vector { element : scalar, count } ,
@@ -753,7 +746,7 @@ impl<'tcx> LayoutCx<'tcx, TyCtxt<'tcx>> {
753746 align = align. min ( AbiAndPrefAlign :: new ( pack) ) ;
754747 }
755748
756- return Ok ( tcx. intern_layout ( LayoutDetails {
749+ return Ok ( tcx. intern_layout ( Layout {
757750 variants : Variants :: Single { index } ,
758751 fields : FieldPlacement :: Union ( variants[ index] . len ( ) ) ,
759752 abi,
@@ -977,7 +970,7 @@ impl<'tcx> LayoutCx<'tcx, TyCtxt<'tcx>> {
977970 let largest_niche =
978971 Niche :: from_scalar ( dl, offset, niche_scalar. clone ( ) ) ;
979972
980- return Ok ( tcx. intern_layout ( LayoutDetails {
973+ return Ok ( tcx. intern_layout ( Layout {
981974 variants : Variants :: Multiple {
982975 discr : niche_scalar,
983976 discr_kind : DiscriminantKind :: Niche {
@@ -1172,7 +1165,7 @@ impl<'tcx> LayoutCx<'tcx, TyCtxt<'tcx>> {
11721165 break ;
11731166 }
11741167 } ;
1175- let prim = match field. details . abi {
1168+ let prim = match field. abi {
11761169 Abi :: Scalar ( ref scalar) => scalar. value ,
11771170 _ => {
11781171 common_prim = None ;
@@ -1219,7 +1212,7 @@ impl<'tcx> LayoutCx<'tcx, TyCtxt<'tcx>> {
12191212
12201213 let largest_niche = Niche :: from_scalar ( dl, Size :: ZERO , tag. clone ( ) ) ;
12211214
1222- tcx. intern_layout ( LayoutDetails {
1215+ tcx. intern_layout ( Layout {
12231216 variants : Variants :: Multiple {
12241217 discr : tag,
12251218 discr_kind : DiscriminantKind :: Tag ,
@@ -1250,7 +1243,7 @@ impl<'tcx> LayoutCx<'tcx, TyCtxt<'tcx>> {
12501243 | ty:: Placeholder ( ..)
12511244 | ty:: UnnormalizedProjection ( ..)
12521245 | ty:: GeneratorWitness ( ..)
1253- | ty:: Infer ( _) => bug ! ( "LayoutDetails ::compute: unexpected type `{}`" , ty) ,
1246+ | ty:: Infer ( _) => bug ! ( "Layout ::compute: unexpected type `{}`" , ty) ,
12541247
12551248 ty:: Param ( _) | ty:: Error => {
12561249 return Err ( LayoutError :: Unknown ( ty) ) ;
@@ -1397,7 +1390,7 @@ impl<'tcx> LayoutCx<'tcx, TyCtxt<'tcx>> {
13971390 ty : Ty < ' tcx > ,
13981391 def_id : hir:: def_id:: DefId ,
13991392 substs : SubstsRef < ' tcx > ,
1400- ) -> Result < & ' tcx LayoutDetails , LayoutError < ' tcx > > {
1393+ ) -> Result < & ' tcx Layout , LayoutError < ' tcx > > {
14011394 use SavedLocalEligibility :: * ;
14021395 let tcx = self . tcx ;
14031396
@@ -1563,7 +1556,7 @@ impl<'tcx> LayoutCx<'tcx, TyCtxt<'tcx>> {
15631556 Abi :: Aggregate { sized : true }
15641557 } ;
15651558
1566- let layout = tcx. intern_layout ( LayoutDetails {
1559+ let layout = tcx. intern_layout ( Layout {
15671560 variants : Variants :: Multiple {
15681561 discr,
15691562 discr_kind : DiscriminantKind :: Tag ,
@@ -1946,8 +1939,8 @@ impl<'tcx> LayoutOf for LayoutCx<'tcx, TyCtxt<'tcx>> {
19461939 fn layout_of ( & self , ty : Ty < ' tcx > ) -> Self :: TyLayout {
19471940 let param_env = self . param_env . with_reveal_all ( ) ;
19481941 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 } ;
19511944
19521945 // N.B., this recording is normally disabled; when enabled, it
19531946 // can however trigger recursive invocations of `layout_of`.
@@ -1970,8 +1963,8 @@ impl LayoutOf for LayoutCx<'tcx, ty::query::TyCtxtAt<'tcx>> {
19701963 fn layout_of ( & self , ty : Ty < ' tcx > ) -> Self :: TyLayout {
19711964 let param_env = self . param_env . with_reveal_all ( ) ;
19721965 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 } ;
19751968
19761969 // N.B., this recording is normally disabled; when enabled, it
19771970 // can however trigger recursive invocations of `layout_of`.
@@ -2020,21 +2013,21 @@ where
20202013 + HasParamEnv < ' tcx > ,
20212014{
20222015 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 ,
20252018
20262019 Variants :: Single { index } => {
20272020 // 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 } ) ;
20302023 }
20312024
20322025 let fields = match this. ty . kind {
20332026 ty:: Adt ( def, _) => def. variants [ variant_index] . fields . len ( ) ,
20342027 _ => bug ! ( ) ,
20352028 } ;
20362029 let tcx = cx. tcx ( ) ;
2037- tcx. intern_layout ( LayoutDetails {
2030+ tcx. intern_layout ( Layout {
20382031 variants : Variants :: Single { index : variant_index } ,
20392032 fields : FieldPlacement :: Union ( fields) ,
20402033 abi : Abi :: Uninhabited ,
@@ -2047,17 +2040,17 @@ where
20472040 Variants :: Multiple { ref variants, .. } => & variants[ variant_index] ,
20482041 } ;
20492042
2050- assert_eq ! ( details . variants, Variants :: Single { index: variant_index } ) ;
2043+ assert_eq ! ( layout . variants, Variants :: Single { index: variant_index } ) ;
20512044
2052- TyLayout { ty : this. ty , details }
2045+ TyLayout { ty : this. ty , layout }
20532046 }
20542047
20552048 fn field ( this : TyLayout < ' tcx > , cx : & C , i : usize ) -> C :: TyLayout {
20562049 let tcx = cx. tcx ( ) ;
20572050 let discr_layout = |discr : & Scalar | -> C :: TyLayout {
2058- let layout = LayoutDetails :: scalar ( cx, discr. clone ( ) ) ;
2051+ let layout = Layout :: scalar ( cx, discr. clone ( ) ) ;
20592052 MaybeResult :: from ( Ok ( TyLayout {
2060- details : tcx. intern_layout ( layout) ,
2053+ layout : tcx. intern_layout ( layout) ,
20612054 ty : discr. value . to_ty ( tcx) ,
20622055 } ) )
20632056 } ;
0 commit comments