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 {
31
31
with_tables ( |t| t. adt_def ( did) )
32
32
}
33
33
34
+ pub fn foreign_def ( did : DefId ) -> stable_mir:: ty:: ForeignDef {
35
+ with_tables ( |t| t. foreign_def ( did) )
36
+ }
37
+
34
38
impl < ' tcx > Tables < ' tcx > {
35
39
pub fn item_def_id ( & self , item : & stable_mir:: CrateItem ) -> DefId {
36
40
self . def_ids [ item. 0 ]
@@ -44,6 +48,10 @@ impl<'tcx> Tables<'tcx> {
44
48
stable_mir:: ty:: AdtDef ( self . create_def_id ( did) )
45
49
}
46
50
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
+
47
55
fn create_def_id ( & mut self , did : DefId ) -> stable_mir:: DefId {
48
56
// FIXME: this becomes inefficient when we have too many ids
49
57
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> {
113
113
. collect ( ) ,
114
114
) ,
115
115
) ) ,
116
- ty:: Foreign ( _) => todo ! ( ) ,
116
+ ty:: Foreign ( def_id) => {
117
+ TyKind :: RigidTy ( RigidTy :: Foreign ( rustc_internal:: foreign_def ( * def_id) ) )
118
+ }
117
119
ty:: Str => TyKind :: RigidTy ( RigidTy :: Str ) ,
118
120
ty:: Array ( ty, constant) => {
119
121
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 {
26
26
Uint ( UintTy ) ,
27
27
Float ( FloatTy ) ,
28
28
Adt ( AdtDef , AdtSubsts ) ,
29
+ Foreign ( ForeignDef ) ,
29
30
Str ,
30
31
Array ( Ty , Const ) ,
31
32
Slice ( Ty ) ,
@@ -60,6 +61,9 @@ pub enum FloatTy {
60
61
F64 ,
61
62
}
62
63
64
+ #[ derive( Clone , PartialEq , Eq , Debug ) ]
65
+ pub struct ForeignDef ( pub ( crate ) DefId ) ;
66
+
63
67
#[ derive( Clone , PartialEq , Eq , Debug ) ]
64
68
pub struct AdtDef ( pub ( crate ) DefId ) ;
65
69
You can’t perform that action at this time.
0 commit comments