Skip to content

Commit

Permalink
Unrolled build for rust-lang#119141
Browse files Browse the repository at this point in the history
Rollup merge of rust-lang#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.
  • Loading branch information
rust-timer authored Dec 21, 2023
2 parents 5ac4c8a + e0a4693 commit 3a603af
Show file tree
Hide file tree
Showing 3 changed files with 15 additions and 0 deletions.
6 changes: 6 additions & 0 deletions compiler/rustc_smir/src/rustc_smir/context.rs
Original file line number Diff line number Diff line change
Expand Up @@ -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];
Expand Down
3 changes: 3 additions & 0 deletions compiler/stable_mir/src/compiler_interface.rs
Original file line number Diff line number Diff line change
Expand Up @@ -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;

Expand Down
6 changes: 6 additions & 0 deletions compiler/stable_mir/src/mir/mono.rs
Original file line number Diff line number Diff line change
Expand Up @@ -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))
Expand Down Expand Up @@ -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()
}
}
Expand Down

0 comments on commit 3a603af

Please sign in to comment.