diff options
| author | Matthias Krüger <matthias.krueger@famsik.de> | 2023-12-20 21:18:59 +0100 |
|---|---|---|
| committer | GitHub <noreply@github.com> | 2023-12-20 21:18:59 +0100 |
| commit | f6a04f693b7e012574a182b9e9b6149402458382 (patch) | |
| tree | 882725e1ee41a359aabe44bbfcb23e69bc72b0c8 | |
| parent | b55887dc7acf822893927da0d2fcdf2774a9f0c8 (diff) | |
| parent | e0a46932943a77bc8394ea9347978a5a20379442 (diff) | |
| download | rust-f6a04f693b7e012574a182b9e9b6149402458382.tar.gz rust-f6a04f693b7e012574a182b9e9b6149402458382.zip | |
Rollup merge of #119141 - celinval:smir-instance-args, r=compiler-errors
Add method to get instance instantiation arguments Add a method to get the instance instantiation arguments, and include that information in the instance debug.
| -rw-r--r-- | compiler/rustc_smir/src/rustc_smir/context.rs | 6 | ||||
| -rw-r--r-- | compiler/stable_mir/src/compiler_interface.rs | 3 | ||||
| -rw-r--r-- | compiler/stable_mir/src/mir/mono.rs | 6 |
3 files changed, 15 insertions, 0 deletions
diff --git a/compiler/rustc_smir/src/rustc_smir/context.rs b/compiler/rustc_smir/src/rustc_smir/context.rs index 621766c695e..f84c466cc44 100644 --- a/compiler/rustc_smir/src/rustc_smir/context.rs +++ b/compiler/rustc_smir/src/rustc_smir/context.rs @@ -341,6 +341,12 @@ impl<'tcx> Context for TablesWrapper<'tcx> { 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> { let mut tables = self.0.borrow_mut(); let instance = tables.instances[def]; diff --git a/compiler/stable_mir/src/compiler_interface.rs b/compiler/stable_mir/src/compiler_interface.rs index 98b1d484c03..f52e506059b 100644 --- a/compiler/stable_mir/src/compiler_interface.rs +++ b/compiler/stable_mir/src/compiler_interface.rs @@ -125,6 +125,9 @@ pub trait Context { /// Get the instance type with generic substitutions applied and lifetimes erased. fn instance_ty(&self, instance: InstanceDef) -> Ty; + /// Get the instantiation types. + fn instance_args(&self, def: InstanceDef) -> GenericArgs; + /// Get the instance. fn instance_def_id(&self, instance: InstanceDef) -> DefId; diff --git a/compiler/stable_mir/src/mir/mono.rs b/compiler/stable_mir/src/mir/mono.rs index 70d44ef8c22..6c791ae8552 100644 --- a/compiler/stable_mir/src/mir/mono.rs +++ b/compiler/stable_mir/src/mir/mono.rs @@ -35,6 +35,11 @@ pub enum InstanceKind { } 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. pub fn body(&self) -> Option<Body> { with(|context| context.instance_body(self.def)) @@ -148,6 +153,7 @@ impl Debug for Instance { f.debug_struct("Instance") .field("kind", &self.kind) .field("def", &self.mangled_name()) + .field("args", &self.args()) .finish() } } |
