about summary refs log tree commit diff
diff options
context:
space:
mode:
authorMatthias Krüger <matthias.krueger@famsik.de>2023-12-12 06:52:51 +0100
committerGitHub <noreply@github.com>2023-12-12 06:52:51 +0100
commitcdc4fc9f35a7d982d98f4c09baa324cb2506aec5 (patch)
tree7a284dfd121f85620c318d67fe5a9f118f0aa1d8
parentfefa8fc6c4136fced5789152f5f07f06219b0a92 (diff)
parent0a65dd305f06fa32eaa494db74c40f5d8616a2e2 (diff)
downloadrust-cdc4fc9f35a7d982d98f4c09baa324cb2506aec5.tar.gz
rust-cdc4fc9f35a7d982d98f4c09baa324cb2506aec5.zip
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``
-rw-r--r--compiler/rustc_smir/src/rustc_smir/builder.rs6
1 files changed, 5 insertions, 1 deletions
diff --git a/compiler/rustc_smir/src/rustc_smir/builder.rs b/compiler/rustc_smir/src/rustc_smir/builder.rs
index 7e74a1d92c7..039bdec4c78 100644
--- a/compiler/rustc_smir/src/rustc_smir/builder.rs
+++ b/compiler/rustc_smir/src/rustc_smir/builder.rs
@@ -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
     }