1
Fork 0

coverageinfo query needs to use the same MIR as codegen

I ran into an error trying to fix dead block coverage and realized the
`coverageinfo` query is getting a different MIR compared to the
codegenned MIR, which can sometimes be a problem during mapgen.

I changed that query to use the `InstandeDef` (which includes the
generic parameter substitutions, prosibly specific to const params)
instead of the `DefId` (without unknown/default const substitutions).
This commit is contained in:
Rich Kadel 2021-05-11 20:56:23 -07:00
parent 31f523ff94
commit aed8ef5a4d
5 changed files with 8 additions and 19 deletions

View file

@ -120,8 +120,8 @@ impl CoverageVisitor {
}
}
fn coverageinfo<'tcx>(tcx: TyCtxt<'tcx>, def_id: DefId) -> CoverageInfo {
let mir_body = mir_body(tcx, def_id);
fn coverageinfo<'tcx>(tcx: TyCtxt<'tcx>, instance_def: ty::InstanceDef<'tcx>) -> CoverageInfo {
let mir_body = tcx.instance_mir(instance_def);
let mut coverage_visitor = CoverageVisitor {
// num_counters always has at least the `ZERO` counter.