coverage: Prepare mappings separately from injecting statements

These two tasks historically needed to be interleaved, but after various recent
changes (including #116046 and #116917) they can now be fully separated.
This commit is contained in:
Zalathar
2023-12-28 13:23:01 +11:00
parent ddca5343f2
commit e1a2babc06
2 changed files with 44 additions and 29 deletions

View File

@@ -48,8 +48,13 @@ impl CoverageSpans {
!self.bcb_to_spans[bcb].is_empty()
}
pub(super) fn spans_for_bcb(&self, bcb: BasicCoverageBlock) -> &[Span] {
&self.bcb_to_spans[bcb]
pub(super) fn bcbs_with_coverage_spans(
&self,
) -> impl Iterator<Item = (BasicCoverageBlock, &[Span])> {
self.bcb_to_spans.iter_enumerated().filter_map(|(bcb, spans)| {
// Only yield BCBs that have at least one coverage span.
(!spans.is_empty()).then_some((bcb, spans.as_slice()))
})
}
}