Add method to get instance instantiation arguments
This commit is contained in:
parent
92ad4b433a
commit
e0a4693294
3 changed files with 15 additions and 0 deletions
|
@ -341,6 +341,12 @@ impl<'tcx> Context for TablesWrapper<'tcx> {
|
||||||
instance.ty(tables.tcx, ParamEnv::reveal_all()).stable(&mut *tables)
|
instance.ty(tables.tcx, ParamEnv::reveal_all()).stable(&mut *tables)
|
||||||
}
|
}
|
||||||
|
|
||||||
|
fn instance_args(&self, def: InstanceDef) -> GenericArgs {
|
||||||
|
let mut tables = self.0.borrow_mut();
|
||||||
|
let instance = tables.instances[def];
|
||||||
|
instance.args.stable(&mut *tables)
|
||||||
|
}
|
||||||
|
|
||||||
fn instance_abi(&self, def: InstanceDef) -> Result<FnAbi, Error> {
|
fn instance_abi(&self, def: InstanceDef) -> Result<FnAbi, Error> {
|
||||||
let mut tables = self.0.borrow_mut();
|
let mut tables = self.0.borrow_mut();
|
||||||
let instance = tables.instances[def];
|
let instance = tables.instances[def];
|
||||||
|
|
|
@ -125,6 +125,9 @@ pub trait Context {
|
||||||
/// Get the instance type with generic substitutions applied and lifetimes erased.
|
/// Get the instance type with generic substitutions applied and lifetimes erased.
|
||||||
fn instance_ty(&self, instance: InstanceDef) -> Ty;
|
fn instance_ty(&self, instance: InstanceDef) -> Ty;
|
||||||
|
|
||||||
|
/// Get the instantiation types.
|
||||||
|
fn instance_args(&self, def: InstanceDef) -> GenericArgs;
|
||||||
|
|
||||||
/// Get the instance.
|
/// Get the instance.
|
||||||
fn instance_def_id(&self, instance: InstanceDef) -> DefId;
|
fn instance_def_id(&self, instance: InstanceDef) -> DefId;
|
||||||
|
|
||||||
|
|
|
@ -35,6 +35,11 @@ pub enum InstanceKind {
|
||||||
}
|
}
|
||||||
|
|
||||||
impl Instance {
|
impl Instance {
|
||||||
|
/// Get the arguments this instance was instantiated with.
|
||||||
|
pub fn args(&self) -> GenericArgs {
|
||||||
|
with(|cx| cx.instance_args(self.def))
|
||||||
|
}
|
||||||
|
|
||||||
/// Get the body of an Instance. The body will be eagerly monomorphized.
|
/// Get the body of an Instance. The body will be eagerly monomorphized.
|
||||||
pub fn body(&self) -> Option<Body> {
|
pub fn body(&self) -> Option<Body> {
|
||||||
with(|context| context.instance_body(self.def))
|
with(|context| context.instance_body(self.def))
|
||||||
|
@ -148,6 +153,7 @@ impl Debug for Instance {
|
||||||
f.debug_struct("Instance")
|
f.debug_struct("Instance")
|
||||||
.field("kind", &self.kind)
|
.field("kind", &self.kind)
|
||||||
.field("def", &self.mangled_name())
|
.field("def", &self.mangled_name())
|
||||||
|
.field("args", &self.args())
|
||||||
.finish()
|
.finish()
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
Loading…
Add table
Add a link
Reference in a new issue