1
Fork 0

coverage: Let each coverage statement hold a vector of code regions

This makes it possible for a `StatementKind::Coverage` to hold more than one
code region, but that capability is not yet used.
This commit is contained in:
Zalathar 2023-08-27 17:11:13 +10:00
parent 1355e1fc74
commit ee9d00f6b8
9 changed files with 96 additions and 90 deletions

View file

@ -93,8 +93,8 @@ fn coverageinfo<'tcx>(tcx: TyCtxt<'tcx>, instance_def: ty::InstanceDef<'tcx>) ->
fn covered_code_regions(tcx: TyCtxt<'_>, def_id: DefId) -> Vec<&CodeRegion> {
let body = mir_body(tcx, def_id);
all_coverage_in_mir_body(body)
// Not all coverage statements have an attached code region.
.filter_map(|coverage| coverage.code_region.as_ref())
// Coverage statements have a list of code regions (possibly empty).
.flat_map(|coverage| coverage.code_regions.as_slice())
.collect()
}