File tree 4 files changed +16
-2
lines changed
rustc_smir/src/rustc_smir
4 files changed +16
-2
lines changed Original file line number Diff line number Diff line change @@ -335,6 +335,12 @@ impl<'tcx> Context for TablesWrapper<'tcx> {
335
335
instance. ty ( tables. tcx , ParamEnv :: reveal_all ( ) ) . stable ( & mut * tables)
336
336
}
337
337
338
+ fn instance_args ( & self , def : InstanceDef ) -> GenericArgs {
339
+ let mut tables = self . 0 . borrow_mut ( ) ;
340
+ let instance = tables. instances [ def] ;
341
+ instance. args . stable ( & mut * tables)
342
+ }
343
+
338
344
fn instance_def_id ( & self , def : InstanceDef ) -> stable_mir:: DefId {
339
345
let mut tables = self . 0 . borrow_mut ( ) ;
340
346
let def_id = tables. instances [ def] . def_id ( ) ;
Original file line number Diff line number Diff line change @@ -85,11 +85,10 @@ pub(crate) fn new_item_kind(kind: DefKind) -> ItemKind {
85
85
| DefKind :: Field
86
86
| DefKind :: LifetimeParam
87
87
| DefKind :: Impl { .. }
88
- | DefKind :: Ctor ( _, _)
89
88
| DefKind :: GlobalAsm => {
90
89
unreachable ! ( "Not a valid item kind: {kind:?}" ) ;
91
90
}
92
- DefKind :: Closure | DefKind :: AssocFn | DefKind :: Fn => ItemKind :: Fn ,
91
+ DefKind :: Ctor ( _ , _ ) | DefKind :: Closure | DefKind :: AssocFn | DefKind :: Fn => ItemKind :: Fn ,
93
92
DefKind :: Const | DefKind :: InlineConst | DefKind :: AssocConst | DefKind :: AnonConst => {
94
93
ItemKind :: Const
95
94
}
Original file line number Diff line number Diff line change @@ -124,6 +124,9 @@ pub trait Context {
124
124
/// Get the instance type with generic substitutions applied and lifetimes erased.
125
125
fn instance_ty ( & self , instance : InstanceDef ) -> Ty ;
126
126
127
+ /// Get the instantiation types.
128
+ fn instance_args ( & self , def : InstanceDef ) -> GenericArgs ;
129
+
127
130
/// Get the instance.
128
131
fn instance_def_id ( & self , instance : InstanceDef ) -> DefId ;
129
132
Original file line number Diff line number Diff line change @@ -34,6 +34,11 @@ pub enum InstanceKind {
34
34
}
35
35
36
36
impl Instance {
37
+ /// Get the arguments this instance was instantiated with.
38
+ pub fn args ( & self ) -> GenericArgs {
39
+ with ( |cx| cx. instance_args ( self . def ) )
40
+ }
41
+
37
42
/// Get the body of an Instance. The body will be eagerly monomorphized.
38
43
pub fn body ( & self ) -> Option < Body > {
39
44
with ( |context| context. instance_body ( self . def ) )
@@ -142,6 +147,7 @@ impl Debug for Instance {
142
147
f. debug_struct ( "Instance" )
143
148
. field ( "kind" , & self . kind )
144
149
. field ( "def" , & self . mangled_name ( ) )
150
+ . field ( "args" , & self . args ( ) )
145
151
. finish ( )
146
152
}
147
153
}
You can’t perform that action at this time.
0 commit comments