File tree Expand file tree Collapse file tree 3 files changed +15
-1
lines changed Expand file tree Collapse file tree 3 files changed +15
-1
lines changed Original file line number Diff line number Diff line change @@ -31,6 +31,10 @@ pub fn adt_def(did: DefId) -> stable_mir::ty::AdtDef {
3131 with_tables ( |t| t. adt_def ( did) )
3232}
3333
34+ pub fn foreign_def ( did : DefId ) -> stable_mir:: ty:: ForeignDef {
35+ with_tables ( |t| t. foreign_def ( did) )
36+ }
37+
3438impl < ' tcx > Tables < ' tcx > {
3539 pub fn item_def_id ( & self , item : & stable_mir:: CrateItem ) -> DefId {
3640 self . def_ids [ item. 0 ]
@@ -44,6 +48,10 @@ impl<'tcx> Tables<'tcx> {
4448 stable_mir:: ty:: AdtDef ( self . create_def_id ( did) )
4549 }
4650
51+ pub fn foreign_def ( & mut self , did : DefId ) -> stable_mir:: ty:: ForeignDef {
52+ stable_mir:: ty:: ForeignDef ( self . create_def_id ( did) )
53+ }
54+
4755 fn create_def_id ( & mut self , did : DefId ) -> stable_mir:: DefId {
4856 // FIXME: this becomes inefficient when we have too many ids
4957 for ( i, & d) in self . def_ids . iter ( ) . enumerate ( ) {
Original file line number Diff line number Diff line change @@ -113,7 +113,9 @@ impl<'tcx> Tables<'tcx> {
113113 . collect ( ) ,
114114 ) ,
115115 ) ) ,
116- ty:: Foreign ( _) => todo ! ( ) ,
116+ ty:: Foreign ( def_id) => {
117+ TyKind :: RigidTy ( RigidTy :: Foreign ( rustc_internal:: foreign_def ( * def_id) ) )
118+ }
117119 ty:: Str => TyKind :: RigidTy ( RigidTy :: Str ) ,
118120 ty:: Array ( ty, constant) => {
119121 TyKind :: RigidTy ( RigidTy :: Array ( self . intern_ty ( * ty) , opaque ( constant) ) )
Original file line number Diff line number Diff line change @@ -26,6 +26,7 @@ pub enum RigidTy {
2626 Uint ( UintTy ) ,
2727 Float ( FloatTy ) ,
2828 Adt ( AdtDef , AdtSubsts ) ,
29+ Foreign ( ForeignDef ) ,
2930 Str ,
3031 Array ( Ty , Const ) ,
3132 Slice ( Ty ) ,
@@ -60,6 +61,9 @@ pub enum FloatTy {
6061 F64 ,
6162}
6263
64+ #[ derive( Clone , PartialEq , Eq , Debug ) ]
65+ pub struct ForeignDef ( pub ( crate ) DefId ) ;
66+
6367#[ derive( Clone , PartialEq , Eq , Debug ) ]
6468pub struct AdtDef ( pub ( crate ) DefId ) ;
6569
You can’t perform that action at this time.
0 commit comments