@@ -12,8 +12,8 @@ use stable_mir::mir::alloc::GlobalAlloc;
12
12
use stable_mir:: mir:: mono:: { InstanceDef , StaticDef } ;
13
13
use stable_mir:: mir:: Body ;
14
14
use stable_mir:: ty:: {
15
- AdtDef , AdtKind , Allocation , ClosureDef , ClosureKind , Const , FnDef , GenericArgs , LineInfo ,
16
- PolyFnSig , RigidTy , Span , TyKind , VariantDef ,
15
+ AdtDef , AdtKind , Allocation , ClosureDef , ClosureKind , Const , FieldDef , FnDef , GenericArgs ,
16
+ LineInfo , PolyFnSig , RigidTy , Span , TyKind , VariantDef ,
17
17
} ;
18
18
use stable_mir:: { self , Crate , CrateItem , DefId , Error , Filename , ItemKind , Symbol } ;
19
19
use std:: cell:: RefCell ;
@@ -219,6 +219,11 @@ impl<'tcx> Context for TablesWrapper<'tcx> {
219
219
def. internal ( & mut * tables) . name . to_string ( )
220
220
}
221
221
222
+ fn variant_fields ( & self , def : VariantDef ) -> Vec < FieldDef > {
223
+ let mut tables = self . 0 . borrow_mut ( ) ;
224
+ def. internal ( & mut * tables) . fields . iter ( ) . map ( |f| f. stable ( & mut * tables) ) . collect ( )
225
+ }
226
+
222
227
fn eval_target_usize ( & self , cnst : & Const ) -> Result < u64 , Error > {
223
228
let mut tables = self . 0 . borrow_mut ( ) ;
224
229
let mir_const = cnst. internal ( & mut * tables) ;
@@ -250,6 +255,18 @@ impl<'tcx> Context for TablesWrapper<'tcx> {
250
255
tables. tcx . type_of ( item. internal ( & mut * tables) ) . instantiate_identity ( ) . stable ( & mut * tables)
251
256
}
252
257
258
+ fn def_ty_with_args (
259
+ & self ,
260
+ item : stable_mir:: DefId ,
261
+ args : & GenericArgs ,
262
+ ) -> Result < stable_mir:: ty:: Ty , Error > {
263
+ let mut tables = self . 0 . borrow_mut ( ) ;
264
+ let args = args. internal ( & mut * tables) ;
265
+ let def_ty = tables. tcx . type_of ( item. internal ( & mut * tables) ) ;
266
+ // FIXME(celinval): use try_fold instead to avoid crashing.
267
+ Ok ( def_ty. instantiate ( tables. tcx , args) . stable ( & mut * tables) )
268
+ }
269
+
253
270
fn const_literal ( & self , cnst : & stable_mir:: ty:: Const ) -> String {
254
271
internal ( cnst) . to_string ( )
255
272
}
0 commit comments