@@ -12,8 +12,8 @@ use stable_mir::mir::alloc::GlobalAlloc;
1212use stable_mir:: mir:: mono:: { InstanceDef , StaticDef } ;
1313use stable_mir:: mir:: Body ;
1414use 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 ,
1717} ;
1818use stable_mir:: { self , Crate , CrateItem , DefId , Error , Filename , ItemKind , Symbol } ;
1919use std:: cell:: RefCell ;
@@ -219,6 +219,11 @@ impl<'tcx> Context for TablesWrapper<'tcx> {
219219 def. internal ( & mut * tables) . name . to_string ( )
220220 }
221221
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+
222227 fn eval_target_usize ( & self , cnst : & Const ) -> Result < u64 , Error > {
223228 let mut tables = self . 0 . borrow_mut ( ) ;
224229 let mir_const = cnst. internal ( & mut * tables) ;
@@ -250,6 +255,18 @@ impl<'tcx> Context for TablesWrapper<'tcx> {
250255 tables. tcx . type_of ( item. internal ( & mut * tables) ) . instantiate_identity ( ) . stable ( & mut * tables)
251256 }
252257
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+
253270 fn const_literal ( & self , cnst : & stable_mir:: ty:: Const ) -> String {
254271 internal ( cnst) . to_string ( )
255272 }
0 commit comments