1
Fork 0

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.
This commit is contained in:
Dylan MacKenzie 2020-10-01 18:47:36 -07:00
parent 6f61e71648
commit 606655edc4

View file

@ -29,7 +29,13 @@ crate fn mir_built<'tcx>(
return tcx.mir_built(def);
}
tcx.alloc_steal_mir(mir_build(tcx, def))
let mut body = mir_build(tcx, def);
if def.const_param_did.is_some() {
assert!(matches!(body.source.instance, ty::InstanceDef::Item(_)));
body.source = MirSource::from_instance(ty::InstanceDef::Item(def.to_global()));
}
tcx.alloc_steal_mir(body)
}
/// Construct the MIR for a given `DefId`.