Skip to content

Commit 606655e

Browse files
HACK: Overwrite the MIR's source with the correct const param
There's a cleaner way of doing this, but it involves passing `WithOptConstParam` around in more places. We're going to try to explore different approaches before committing to that.
1 parent 6f61e71 commit 606655e

File tree

1 file changed

+7
-1
lines changed
  • compiler/rustc_mir_build/src/build

1 file changed

+7
-1
lines changed

compiler/rustc_mir_build/src/build/mod.rs

+7-1
Original file line numberDiff line numberDiff line change
@@ -29,7 +29,13 @@ crate fn mir_built<'tcx>(
2929
return tcx.mir_built(def);
3030
}
3131

32-
tcx.alloc_steal_mir(mir_build(tcx, def))
32+
let mut body = mir_build(tcx, def);
33+
if def.const_param_did.is_some() {
34+
assert!(matches!(body.source.instance, ty::InstanceDef::Item(_)));
35+
body.source = MirSource::from_instance(ty::InstanceDef::Item(def.to_global()));
36+
}
37+
38+
tcx.alloc_steal_mir(body)
3339
}
3440

3541
/// Construct the MIR for a given `DefId`.

0 commit comments

Comments
 (0)