Rollup merge of #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``
This commit is contained in:
Matthias Krüger 2023-12-12 06:52:51 +01:00 committed by GitHub
commit cdc4fc9f35
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23

View File

@ -6,7 +6,7 @@
use crate::rustc_smir::{Stable, Tables};
use rustc_middle::mir;
use rustc_middle::mir::visit::MutVisitor;
use rustc_middle::ty::{self, Ty, TyCtxt};
use rustc_middle::ty::{self, GenericArgsRef, Ty, TyCtxt};
/// Builds a monomorphic body for a given instance.
pub struct BodyBuilder<'tcx> {
@ -68,6 +68,10 @@ impl<'tcx> MutVisitor<'tcx> for BodyBuilder<'tcx> {
self.super_constant(constant, location);
}
fn visit_args(&mut self, args: &mut GenericArgsRef<'tcx>, _: mir::Location) {
*args = self.monomorphize(*args);
}
fn tcx(&self) -> TyCtxt<'tcx> {
self.tcx
}