Skip to content

Commit cdc4fc9

Browse files
authored
Rollup merge of rust-lang#118844 - celinval:smir-mono-args, r=compiler-errors
Monomorphize args while building Instance body in StableMIR The function `Instance::body()` in StableMIR is supposed to return a monomorphic body by instantiating all possibly generic constructs. We were previously instantiating type and constants, but not generic arguments. This PR ensures that we also instantiate them. r? ``@compiler-errors``
2 parents fefa8fc + 0a65dd3 commit cdc4fc9

File tree

1 file changed

+5
-1
lines changed

1 file changed

+5
-1
lines changed

compiler/rustc_smir/src/rustc_smir/builder.rs

+5-1
Original file line numberDiff line numberDiff line change
@@ -6,7 +6,7 @@
66
use crate::rustc_smir::{Stable, Tables};
77
use rustc_middle::mir;
88
use rustc_middle::mir::visit::MutVisitor;
9-
use rustc_middle::ty::{self, Ty, TyCtxt};
9+
use rustc_middle::ty::{self, GenericArgsRef, Ty, TyCtxt};
1010

1111
/// Builds a monomorphic body for a given instance.
1212
pub struct BodyBuilder<'tcx> {
@@ -68,6 +68,10 @@ impl<'tcx> MutVisitor<'tcx> for BodyBuilder<'tcx> {
6868
self.super_constant(constant, location);
6969
}
7070

71+
fn visit_args(&mut self, args: &mut GenericArgsRef<'tcx>, _: mir::Location) {
72+
*args = self.monomorphize(*args);
73+
}
74+
7175
fn tcx(&self) -> TyCtxt<'tcx> {
7276
self.tcx
7377
}

0 commit comments

Comments
 (0)