mirror of
https://github.com/rust-lang/rust.git
synced 2025-05-14 02:49:40 +00:00
coverage: Return a nested vector from initial span extraction
This will allow the span extractor to produce multiple separate buckets, instead of just one flat list of spans.
This commit is contained in:
parent
df96cba432
commit
9c931c01f7
@ -20,13 +20,16 @@ pub(super) fn extract_refined_covspans(
|
||||
basic_coverage_blocks: &CoverageGraph,
|
||||
code_mappings: &mut impl Extend<mappings::CodeMapping>,
|
||||
) {
|
||||
let sorted_spans =
|
||||
let sorted_span_buckets =
|
||||
from_mir::mir_to_initial_sorted_coverage_spans(mir_body, hir_info, basic_coverage_blocks);
|
||||
let coverage_spans = SpansRefiner::refine_sorted_spans(sorted_spans);
|
||||
code_mappings.extend(coverage_spans.into_iter().map(|RefinedCovspan { bcb, span, .. }| {
|
||||
// Each span produced by the generator represents an ordinary code region.
|
||||
mappings::CodeMapping { span, bcb }
|
||||
}));
|
||||
for bucket in sorted_span_buckets {
|
||||
let refined_spans = SpansRefiner::refine_sorted_spans(bucket);
|
||||
code_mappings.extend(refined_spans.into_iter().map(|covspan| {
|
||||
let RefinedCovspan { span, bcb, is_hole: _ } = covspan;
|
||||
// Each span produced by the refiner represents an ordinary code region.
|
||||
mappings::CodeMapping { span, bcb }
|
||||
}));
|
||||
}
|
||||
}
|
||||
|
||||
#[derive(Debug)]
|
||||
|
@ -23,7 +23,7 @@ pub(super) fn mir_to_initial_sorted_coverage_spans(
|
||||
mir_body: &mir::Body<'_>,
|
||||
hir_info: &ExtractedHirInfo,
|
||||
basic_coverage_blocks: &CoverageGraph,
|
||||
) -> Vec<SpanFromMir> {
|
||||
) -> Vec<Vec<SpanFromMir>> {
|
||||
let &ExtractedHirInfo { body_span, .. } = hir_info;
|
||||
|
||||
let mut initial_spans = vec![];
|
||||
@ -67,7 +67,7 @@ pub(super) fn mir_to_initial_sorted_coverage_spans(
|
||||
// requires a lot more complexity in the span refiner, for little benefit.)
|
||||
initial_spans.dedup_by(|b, a| a.span.source_equal(b.span));
|
||||
|
||||
initial_spans
|
||||
vec![initial_spans]
|
||||
}
|
||||
|
||||
/// Macros that expand into branches (e.g. `assert!`, `trace!`) tend to generate
|
||||
|
Loading…
Reference in New Issue
Block a user