@@ -179,7 +179,7 @@ pub(crate) mod rustc {
179
179
} ;
180
180
181
181
use super :: Tree ;
182
- use crate :: layout:: rustc:: { Def , Ref } ;
182
+ use crate :: layout:: rustc:: { layout_of , Def , Ref } ;
183
183
184
184
#[ derive( Debug , Copy , Clone ) ]
185
185
pub ( crate ) enum Err {
@@ -206,7 +206,7 @@ pub(crate) mod rustc {
206
206
impl < ' tcx > Tree < Def < ' tcx > , Ref < ' tcx > > {
207
207
pub fn from_ty ( ty : Ty < ' tcx > , cx : LayoutCx < ' tcx , TyCtxt < ' tcx > > ) -> Result < Self , Err > {
208
208
use rustc_target:: abi:: HasDataLayout ;
209
- let layout = ty_layout ( cx, ty) ;
209
+ let layout = layout_of ( cx, ty) ? ;
210
210
211
211
if let Err ( e) = ty. error_reported ( ) {
212
212
return Err ( Err :: TypeError ( e) ) ;
@@ -239,7 +239,7 @@ pub(crate) mod rustc {
239
239
let FieldsShape :: Array { stride, count } = & layout. fields else {
240
240
return Err ( Err :: NotYetSupported ) ;
241
241
} ;
242
- let inner_layout = ty_layout ( cx, * inner_ty) ;
242
+ let inner_layout = layout_of ( cx, * inner_ty) ? ;
243
243
assert_eq ! ( * stride, inner_layout. size) ;
244
244
let elt = Tree :: from_ty ( * inner_ty, cx) ?;
245
245
Ok ( std:: iter:: repeat ( elt)
@@ -254,7 +254,7 @@ pub(crate) mod rustc {
254
254
} ,
255
255
256
256
ty:: Ref ( lifetime, ty, mutability) => {
257
- let layout = ty_layout ( cx, * ty) ;
257
+ let layout = layout_of ( cx, * ty) ? ;
258
258
let align = layout. align . abi . bytes_usize ( ) ;
259
259
let size = layout. size . bytes_usize ( ) ;
260
260
Ok ( Tree :: Ref ( Ref {
@@ -280,7 +280,7 @@ pub(crate) mod rustc {
280
280
FieldsShape :: Primitive => {
281
281
assert_eq ! ( members. len( ) , 1 ) ;
282
282
let inner_ty = members[ 0 ] ;
283
- let inner_layout = ty_layout ( cx, inner_ty) ;
283
+ let inner_layout = layout_of ( cx, inner_ty) ? ;
284
284
Self :: from_ty ( inner_ty, cx)
285
285
}
286
286
FieldsShape :: Arbitrary { offsets, .. } => {
@@ -413,7 +413,7 @@ pub(crate) mod rustc {
413
413
let padding = Self :: padding ( padding_needed. bytes_usize ( ) ) ;
414
414
415
415
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) ? ;
417
417
let field_tree = Self :: from_ty ( field_ty, cx) ?;
418
418
419
419
struct_tree = struct_tree. then ( padding) . then ( field_tree) ;
@@ -471,7 +471,7 @@ pub(crate) mod rustc {
471
471
|fields, ( idx, field_def) | {
472
472
let field_def = Def :: Field ( field_def) ;
473
473
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) ? ;
475
475
let field = Self :: from_ty ( field_ty, cx) ?;
476
476
let trailing_padding_needed = layout. size - field_layout. size ;
477
477
let trailing_padding = Self :: padding ( trailing_padding_needed. bytes_usize ( ) ) ;
@@ -484,10 +484,6 @@ pub(crate) mod rustc {
484
484
}
485
485
}
486
486
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
-
491
487
fn ty_field < ' tcx > (
492
488
cx : LayoutCx < ' tcx , TyCtxt < ' tcx > > ,
493
489
( ty, layout) : ( Ty < ' tcx > , Layout < ' tcx > ) ,
0 commit comments