@@ -183,7 +183,7 @@ impl<'tcx> fmt::Display for LayoutError<'tcx> {
183183fn layout_raw < ' tcx > (
184184 tcx : TyCtxt < ' tcx > ,
185185 query : ty:: ParamEnvAnd < ' tcx , Ty < ' tcx > > ,
186- ) -> Result < & ' tcx LayoutDetails , LayoutError < ' tcx > > {
186+ ) -> Result < & ' tcx Layout , LayoutError < ' tcx > > {
187187 ty:: tls:: with_related_context ( tcx, move |icx| {
188188 let rec_limit = * tcx. sess . recursion_limit . get ( ) ;
189189 let ( param_env, ty) = query. into_parts ( ) ;
@@ -242,7 +242,7 @@ fn invert_mapping(map: &[u32]) -> Vec<u32> {
242242}
243243
244244impl < ' 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 {
246246 let dl = self . data_layout ( ) ;
247247 let b_align = b. value . align ( dl) ;
248248 let align = a. value . align ( dl) . max ( b_align) . max ( dl. aggregate_align ) ;
@@ -256,7 +256,7 @@ impl<'tcx> LayoutCx<'tcx, TyCtxt<'tcx>> {
256256 . chain ( Niche :: from_scalar ( dl, Size :: ZERO , a. clone ( ) ) )
257257 . max_by_key ( |niche| niche. available ( dl) ) ;
258258
259- LayoutDetails {
259+ Layout {
260260 variants : Variants :: Single { index : VariantIdx :: new ( 0 ) } ,
261261 fields : FieldPlacement :: Arbitrary {
262262 offsets : vec ! [ Size :: ZERO , b_offset] ,
@@ -275,7 +275,7 @@ impl<'tcx> LayoutCx<'tcx, TyCtxt<'tcx>> {
275275 fields : & [ TyLayout < ' _ > ] ,
276276 repr : & ReprOptions ,
277277 kind : StructKind ,
278- ) -> Result < LayoutDetails , LayoutError < ' tcx > > {
278+ ) -> Result < Layout , LayoutError < ' tcx > > {
279279 let dl = self . data_layout ( ) ;
280280 let pack = repr. pack ;
281281 if pack. is_some ( ) && repr. align . is_some ( ) {
@@ -428,17 +428,11 @@ impl<'tcx> LayoutCx<'tcx, TyCtxt<'tcx>> {
428428 (
429429 Some ( (
430430 i,
431- & TyLayout {
432- details : & LayoutDetails { abi : Abi :: Scalar ( ref a) , .. } ,
433- ..
434- } ,
431+ & TyLayout { layout : & Layout { abi : Abi :: Scalar ( ref a) , .. } , .. } ,
435432 ) ) ,
436433 Some ( (
437434 j,
438- & TyLayout {
439- details : & LayoutDetails { abi : Abi :: Scalar ( ref b) , .. } ,
440- ..
441- } ,
435+ & TyLayout { layout : & Layout { abi : Abi :: Scalar ( ref b) , .. } , .. } ,
442436 ) ) ,
443437 None ,
444438 ) => {
@@ -476,7 +470,7 @@ impl<'tcx> LayoutCx<'tcx, TyCtxt<'tcx>> {
476470 abi = Abi :: Uninhabited ;
477471 }
478472
479- Ok ( LayoutDetails {
473+ Ok ( Layout {
480474 variants : Variants :: Single { index : VariantIdx :: new ( 0 ) } ,
481475 fields : FieldPlacement :: Arbitrary { offsets, memory_index } ,
482476 abi,
@@ -486,7 +480,7 @@ impl<'tcx> LayoutCx<'tcx, TyCtxt<'tcx>> {
486480 } )
487481 }
488482
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 > > {
490484 let tcx = self . tcx ;
491485 let param_env = self . param_env ;
492486 let dl = self . data_layout ( ) ;
@@ -495,8 +489,7 @@ impl<'tcx> LayoutCx<'tcx, TyCtxt<'tcx>> {
495489 assert ! ( bits <= 128 ) ;
496490 Scalar { value, valid_range : 0 ..=( !0 >> ( 128 - bits) ) }
497491 } ;
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) ) ) ;
500493
501494 let univariant = |fields : & [ TyLayout < ' _ > ] , repr : & ReprOptions , kind| {
502495 Ok ( tcx. intern_layout ( self . univariant_uninterned ( ty, fields, repr, kind) ?) )
@@ -505,11 +498,11 @@ impl<'tcx> LayoutCx<'tcx, TyCtxt<'tcx>> {
505498
506499 Ok ( match ty. kind {
507500 // Basic scalars.
508- ty:: Bool => tcx. intern_layout ( LayoutDetails :: scalar (
501+ ty:: Bool => tcx. intern_layout ( Layout :: scalar (
509502 self ,
510503 Scalar { value : Int ( I8 , false ) , valid_range : 0 ..=1 } ,
511504 ) ) ,
512- ty:: Char => tcx. intern_layout ( LayoutDetails :: scalar (
505+ ty:: Char => tcx. intern_layout ( Layout :: scalar (
513506 self ,
514507 Scalar { value : Int ( I32 , false ) , valid_range : 0 ..=0x10FFFF } ,
515508 ) ) ,
@@ -522,11 +515,11 @@ impl<'tcx> LayoutCx<'tcx, TyCtxt<'tcx>> {
522515 ty:: FnPtr ( _) => {
523516 let mut ptr = scalar_unit ( Pointer ) ;
524517 ptr. valid_range = 1 ..=* ptr. valid_range . end ( ) ;
525- tcx. intern_layout ( LayoutDetails :: scalar ( self , ptr) )
518+ tcx. intern_layout ( Layout :: scalar ( self , ptr) )
526519 }
527520
528521 // The never type.
529- ty:: Never => tcx. intern_layout ( LayoutDetails {
522+ ty:: Never => tcx. intern_layout ( Layout {
530523 variants : Variants :: Single { index : VariantIdx :: new ( 0 ) } ,
531524 fields : FieldPlacement :: Union ( 0 ) ,
532525 abi : Abi :: Uninhabited ,
@@ -544,13 +537,13 @@ impl<'tcx> LayoutCx<'tcx, TyCtxt<'tcx>> {
544537
545538 let pointee = tcx. normalize_erasing_regions ( param_env, pointee) ;
546539 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) ) ) ;
548541 }
549542
550543 let unsized_part = tcx. struct_tail_erasing_lifetimes ( pointee, param_env) ;
551544 let metadata = match unsized_part. kind {
552545 ty:: Foreign ( ..) => {
553- return Ok ( tcx. intern_layout ( LayoutDetails :: scalar ( self , data_ptr) ) ) ;
546+ return Ok ( tcx. intern_layout ( Layout :: scalar ( self , data_ptr) ) ) ;
554547 }
555548 ty:: Slice ( _) | ty:: Str => scalar_unit ( Int ( dl. ptr_sized_integer ( ) , false ) ) ,
556549 ty:: Dynamic ( ..) => {
@@ -587,7 +580,7 @@ impl<'tcx> LayoutCx<'tcx, TyCtxt<'tcx>> {
587580
588581 let largest_niche = if count != 0 { element. largest_niche . clone ( ) } else { None } ;
589582
590- tcx. intern_layout ( LayoutDetails {
583+ tcx. intern_layout ( Layout {
591584 variants : Variants :: Single { index : VariantIdx :: new ( 0 ) } ,
592585 fields : FieldPlacement :: Array { stride : element. size , count } ,
593586 abi,
@@ -598,7 +591,7 @@ impl<'tcx> LayoutCx<'tcx, TyCtxt<'tcx>> {
598591 }
599592 ty:: Slice ( element) => {
600593 let element = self . layout_of ( element) ?;
601- tcx. intern_layout ( LayoutDetails {
594+ tcx. intern_layout ( Layout {
602595 variants : Variants :: Single { index : VariantIdx :: new ( 0 ) } ,
603596 fields : FieldPlacement :: Array { stride : element. size , count : 0 } ,
604597 abi : Abi :: Aggregate { sized : false } ,
@@ -607,7 +600,7 @@ impl<'tcx> LayoutCx<'tcx, TyCtxt<'tcx>> {
607600 size : Size :: ZERO ,
608601 } )
609602 }
610- ty:: Str => tcx. intern_layout ( LayoutDetails {
603+ ty:: Str => tcx. intern_layout ( Layout {
611604 variants : Variants :: Single { index : VariantIdx :: new ( 0 ) } ,
612605 fields : FieldPlacement :: Array { stride : Size :: from_bytes ( 1 ) , count : 0 } ,
613606 abi : Abi :: Aggregate { sized : false } ,
@@ -676,7 +669,7 @@ impl<'tcx> LayoutCx<'tcx, TyCtxt<'tcx>> {
676669 let align = dl. vector_align ( size) ;
677670 let size = size. align_to ( align. abi ) ;
678671
679- tcx. intern_layout ( LayoutDetails {
672+ tcx. intern_layout ( Layout {
680673 variants : Variants :: Single { index : VariantIdx :: new ( 0 ) } ,
681674 fields : FieldPlacement :: Array { stride : element. size , count } ,
682675 abi : Abi :: Vector { element : scalar, count } ,
@@ -752,7 +745,7 @@ impl<'tcx> LayoutCx<'tcx, TyCtxt<'tcx>> {
752745 align = align. min ( AbiAndPrefAlign :: new ( pack) ) ;
753746 }
754747
755- return Ok ( tcx. intern_layout ( LayoutDetails {
748+ return Ok ( tcx. intern_layout ( Layout {
756749 variants : Variants :: Single { index } ,
757750 fields : FieldPlacement :: Union ( variants[ index] . len ( ) ) ,
758751 abi,
@@ -976,7 +969,7 @@ impl<'tcx> LayoutCx<'tcx, TyCtxt<'tcx>> {
976969 let largest_niche =
977970 Niche :: from_scalar ( dl, offset, niche_scalar. clone ( ) ) ;
978971
979- return Ok ( tcx. intern_layout ( LayoutDetails {
972+ return Ok ( tcx. intern_layout ( Layout {
980973 variants : Variants :: Multiple {
981974 discr : niche_scalar,
982975 discr_kind : DiscriminantKind :: Niche {
@@ -1171,7 +1164,7 @@ impl<'tcx> LayoutCx<'tcx, TyCtxt<'tcx>> {
11711164 break ;
11721165 }
11731166 } ;
1174- let prim = match field. details . abi {
1167+ let prim = match field. abi {
11751168 Abi :: Scalar ( ref scalar) => scalar. value ,
11761169 _ => {
11771170 common_prim = None ;
@@ -1218,7 +1211,7 @@ impl<'tcx> LayoutCx<'tcx, TyCtxt<'tcx>> {
12181211
12191212 let largest_niche = Niche :: from_scalar ( dl, Size :: ZERO , tag. clone ( ) ) ;
12201213
1221- tcx. intern_layout ( LayoutDetails {
1214+ tcx. intern_layout ( Layout {
12221215 variants : Variants :: Multiple {
12231216 discr : tag,
12241217 discr_kind : DiscriminantKind :: Tag ,
@@ -1249,7 +1242,7 @@ impl<'tcx> LayoutCx<'tcx, TyCtxt<'tcx>> {
12491242 | ty:: Placeholder ( ..)
12501243 | ty:: UnnormalizedProjection ( ..)
12511244 | ty:: GeneratorWitness ( ..)
1252- | ty:: Infer ( _) => bug ! ( "LayoutDetails ::compute: unexpected type `{}`" , ty) ,
1245+ | ty:: Infer ( _) => bug ! ( "Layout ::compute: unexpected type `{}`" , ty) ,
12531246
12541247 ty:: Param ( _) | ty:: Error => {
12551248 return Err ( LayoutError :: Unknown ( ty) ) ;
@@ -1396,7 +1389,7 @@ impl<'tcx> LayoutCx<'tcx, TyCtxt<'tcx>> {
13961389 ty : Ty < ' tcx > ,
13971390 def_id : hir:: def_id:: DefId ,
13981391 substs : SubstsRef < ' tcx > ,
1399- ) -> Result < & ' tcx LayoutDetails , LayoutError < ' tcx > > {
1392+ ) -> Result < & ' tcx Layout , LayoutError < ' tcx > > {
14001393 use SavedLocalEligibility :: * ;
14011394 let tcx = self . tcx ;
14021395
@@ -1562,7 +1555,7 @@ impl<'tcx> LayoutCx<'tcx, TyCtxt<'tcx>> {
15621555 Abi :: Aggregate { sized : true }
15631556 } ;
15641557
1565- let layout = tcx. intern_layout ( LayoutDetails {
1558+ let layout = tcx. intern_layout ( Layout {
15661559 variants : Variants :: Multiple {
15671560 discr,
15681561 discr_kind : DiscriminantKind :: Tag ,
@@ -1945,8 +1938,8 @@ impl<'tcx> LayoutOf for LayoutCx<'tcx, TyCtxt<'tcx>> {
19451938 fn layout_of ( & self , ty : Ty < ' tcx > ) -> Self :: TyLayout {
19461939 let param_env = self . param_env . with_reveal_all ( ) ;
19471940 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 } ;
19501943
19511944 // N.B., this recording is normally disabled; when enabled, it
19521945 // can however trigger recursive invocations of `layout_of`.
@@ -1969,8 +1962,8 @@ impl LayoutOf for LayoutCx<'tcx, ty::query::TyCtxtAt<'tcx>> {
19691962 fn layout_of ( & self , ty : Ty < ' tcx > ) -> Self :: TyLayout {
19701963 let param_env = self . param_env . with_reveal_all ( ) ;
19711964 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 } ;
19741967
19751968 // N.B., this recording is normally disabled; when enabled, it
19761969 // can however trigger recursive invocations of `layout_of`.
@@ -2019,21 +2012,21 @@ where
20192012 + HasParamEnv < ' tcx > ,
20202013{
20212014 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 ,
20242017
20252018 Variants :: Single { index } => {
20262019 // 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 } ) ;
20292022 }
20302023
20312024 let fields = match this. ty . kind {
20322025 ty:: Adt ( def, _) => def. variants [ variant_index] . fields . len ( ) ,
20332026 _ => bug ! ( ) ,
20342027 } ;
20352028 let tcx = cx. tcx ( ) ;
2036- tcx. intern_layout ( LayoutDetails {
2029+ tcx. intern_layout ( Layout {
20372030 variants : Variants :: Single { index : variant_index } ,
20382031 fields : FieldPlacement :: Union ( fields) ,
20392032 abi : Abi :: Uninhabited ,
@@ -2046,17 +2039,17 @@ where
20462039 Variants :: Multiple { ref variants, .. } => & variants[ variant_index] ,
20472040 } ;
20482041
2049- assert_eq ! ( details . variants, Variants :: Single { index: variant_index } ) ;
2042+ assert_eq ! ( layout . variants, Variants :: Single { index: variant_index } ) ;
20502043
2051- TyLayout { ty : this. ty , details }
2044+ TyLayout { ty : this. ty , layout }
20522045 }
20532046
20542047 fn field ( this : TyLayout < ' tcx > , cx : & C , i : usize ) -> C :: TyLayout {
20552048 let tcx = cx. tcx ( ) ;
20562049 let discr_layout = |discr : & Scalar | -> C :: TyLayout {
2057- let layout = LayoutDetails :: scalar ( cx, discr. clone ( ) ) ;
2050+ let layout = Layout :: scalar ( cx, discr. clone ( ) ) ;
20582051 MaybeResult :: from ( Ok ( TyLayout {
2059- details : tcx. intern_layout ( layout) ,
2052+ layout : tcx. intern_layout ( layout) ,
20602053 ty : discr. value . to_ty ( tcx) ,
20612054 } ) )
20622055 } ;
0 commit comments