Skip to content

Commit

Permalink
Unrolled build for rust-lang#118844
Browse files Browse the repository at this point in the history
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``
  • Loading branch information
rust-timer committed Dec 12, 2023
2 parents 5f5d248 + 0a65dd3 commit 57d2e89
Showing 1 changed file with 5 additions and 1 deletion.
6 changes: 5 additions & 1 deletion compiler/rustc_smir/src/rustc_smir/builder.rs
Original file line number Diff line number Diff line change
Expand Up @@ -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> {
Expand Down Expand Up @@ -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
}
Expand Down

0 comments on commit 57d2e89

Please sign in to comment.