diff options
| author | Zalathar <Zalathar@users.noreply.github.com> | 2025-03-04 13:53:24 +1100 |
|---|---|---|
| committer | Zalathar <Zalathar@users.noreply.github.com> | 2025-03-21 21:23:50 +1100 |
| commit | 7fdac5eef09a11fd4f35ab272d83f5ea08b15320 (patch) | |
| tree | bb848b21fed1a062b6d0db2ab5550eb460e2cd0b /compiler/rustc_mir_transform/src/coverage/spans.rs | |
| parent | 83b56eb059d9e47864191fc13783f44f04cb42b4 (diff) | |
| download | rust-7fdac5eef09a11fd4f35ab272d83f5ea08b15320.tar.gz rust-7fdac5eef09a11fd4f35ab272d83f5ea08b15320.zip | |
coverage: Defer the filtering of hole spans
Diffstat (limited to 'compiler/rustc_mir_transform/src/coverage/spans.rs')
| -rw-r--r-- | compiler/rustc_mir_transform/src/coverage/spans.rs | 9 |
1 files changed, 8 insertions, 1 deletions
diff --git a/compiler/rustc_mir_transform/src/coverage/spans.rs b/compiler/rustc_mir_transform/src/coverage/spans.rs index f63ccff8dec..8befe9c5d8d 100644 --- a/compiler/rustc_mir_transform/src/coverage/spans.rs +++ b/compiler/rustc_mir_transform/src/coverage/spans.rs @@ -69,7 +69,14 @@ pub(super) fn extract_refined_covspans( covspans.dedup_by(|b, a| a.span.source_equal(b.span)); // Sort the holes, and merge overlapping/adjacent holes. - let mut holes = hir_info.hole_spans.iter().map(|&span| Hole { span }).collect::<Vec<_>>(); + let mut holes = hir_info + .hole_spans + .iter() + .copied() + // Discard any holes that aren't directly visible within the body span. + .filter(|&hole_span| body_span.contains(hole_span) && body_span.eq_ctxt(hole_span)) + .map(|span| Hole { span }) + .collect::<Vec<_>>(); holes.sort_by(|a, b| compare_spans(a.span, b.span)); holes.dedup_by(|b, a| a.merge_if_overlapping_or_adjacent(b)); |
