@@ -179,7 +179,7 @@ pub(crate) mod rustc {
179179 } ;
180180
181181 use super :: Tree ;
182- use crate :: layout:: rustc:: { Def , Ref } ;
182+ use crate :: layout:: rustc:: { layout_of , Def , Ref } ;
183183
184184 #[ derive( Debug , Copy , Clone ) ]
185185 pub ( crate ) enum Err {
@@ -206,7 +206,7 @@ pub(crate) mod rustc {
206206 impl < ' tcx > Tree < Def < ' tcx > , Ref < ' tcx > > {
207207 pub fn from_ty ( ty : Ty < ' tcx > , cx : LayoutCx < ' tcx , TyCtxt < ' tcx > > ) -> Result < Self , Err > {
208208 use rustc_target:: abi:: HasDataLayout ;
209- let layout = ty_layout ( cx, ty) ;
209+ let layout = layout_of ( cx, ty) ? ;
210210
211211 if let Err ( e) = ty. error_reported ( ) {
212212 return Err ( Err :: TypeError ( e) ) ;
@@ -239,7 +239,7 @@ pub(crate) mod rustc {
239239 let FieldsShape :: Array { stride, count } = & layout. fields else {
240240 return Err ( Err :: NotYetSupported ) ;
241241 } ;
242- let inner_layout = ty_layout ( cx, * inner_ty) ;
242+ let inner_layout = layout_of ( cx, * inner_ty) ? ;
243243 assert_eq ! ( * stride, inner_layout. size) ;
244244 let elt = Tree :: from_ty ( * inner_ty, cx) ?;
245245 Ok ( std:: iter:: repeat ( elt)
@@ -254,7 +254,7 @@ pub(crate) mod rustc {
254254 } ,
255255
256256 ty:: Ref ( lifetime, ty, mutability) => {
257- let layout = ty_layout ( cx, * ty) ;
257+ let layout = layout_of ( cx, * ty) ? ;
258258 let align = layout. align . abi . bytes_usize ( ) ;
259259 let size = layout. size . bytes_usize ( ) ;
260260 Ok ( Tree :: Ref ( Ref {
@@ -280,7 +280,7 @@ pub(crate) mod rustc {
280280 FieldsShape :: Primitive => {
281281 assert_eq ! ( members. len( ) , 1 ) ;
282282 let inner_ty = members[ 0 ] ;
283- let inner_layout = ty_layout ( cx, inner_ty) ;
283+ let inner_layout = layout_of ( cx, inner_ty) ? ;
284284 Self :: from_ty ( inner_ty, cx)
285285 }
286286 FieldsShape :: Arbitrary { offsets, .. } => {
@@ -413,7 +413,7 @@ pub(crate) mod rustc {
413413 let padding = Self :: padding ( padding_needed. bytes_usize ( ) ) ;
414414
415415 let field_ty = ty_field ( cx, ( ty, layout) , field_idx) ;
416- let field_layout = ty_layout ( cx, field_ty) ;
416+ let field_layout = layout_of ( cx, field_ty) ? ;
417417 let field_tree = Self :: from_ty ( field_ty, cx) ?;
418418
419419 struct_tree = struct_tree. then ( padding) . then ( field_tree) ;
@@ -471,7 +471,7 @@ pub(crate) mod rustc {
471471 |fields, ( idx, field_def) | {
472472 let field_def = Def :: Field ( field_def) ;
473473 let field_ty = ty_field ( cx, ( ty, layout) , idx) ;
474- let field_layout = ty_layout ( cx, field_ty) ;
474+ let field_layout = layout_of ( cx, field_ty) ? ;
475475 let field = Self :: from_ty ( field_ty, cx) ?;
476476 let trailing_padding_needed = layout. size - field_layout. size ;
477477 let trailing_padding = Self :: padding ( trailing_padding_needed. bytes_usize ( ) ) ;
@@ -484,10 +484,6 @@ pub(crate) mod rustc {
484484 }
485485 }
486486
487- pub ( crate ) fn ty_layout < ' tcx > ( cx : LayoutCx < ' tcx , TyCtxt < ' tcx > > , ty : Ty < ' tcx > ) -> Layout < ' tcx > {
488- crate :: layout:: rustc:: layout_of ( cx, ty) . unwrap ( )
489- }
490-
491487 fn ty_field < ' tcx > (
492488 cx : LayoutCx < ' tcx , TyCtxt < ' tcx > > ,
493489 ( ty, layout) : ( Ty < ' tcx > , Layout < ' tcx > ) ,
0 commit comments