@@ -59,8 +59,15 @@ pub(super) fn extract_refined_covspans(
59
59
for mut covspans in buckets {
60
60
// Make sure each individual bucket is internally sorted.
61
61
covspans. sort_by ( compare_covspans) ;
62
+ let _span = debug_span ! ( "processing bucket" , ?covspans) . entered ( ) ;
63
+
64
+ let mut covspans = remove_unwanted_overlapping_spans ( covspans) ;
65
+ debug ! ( ?covspans, "after removing overlaps" ) ;
66
+
67
+ // Do one last merge pass, to simplify the output.
68
+ covspans. dedup_by ( |b, a| a. merge_if_eligible ( b) ) ;
69
+ debug ! ( ?covspans, "after merge" ) ;
62
70
63
- let covspans = refine_sorted_spans ( covspans) ;
64
71
code_mappings. extend ( covspans. into_iter ( ) . map ( |Covspan { span, bcb } | {
65
72
// Each span produced by the refiner represents an ordinary code region.
66
73
mappings:: CodeMapping { span, bcb }
@@ -177,10 +184,11 @@ fn drain_front_while<'a, T>(
177
184
}
178
185
179
186
/// Takes one of the buckets of (sorted) spans extracted from MIR, and "refines"
180
- /// those spans by removing spans that overlap in unwanted ways, and by merging
181
- /// compatible adjacent spans.
187
+ /// those spans by removing spans that overlap in unwanted ways.
182
188
#[ instrument( level = "debug" ) ]
183
- fn refine_sorted_spans ( sorted_spans : Vec < Covspan > ) -> Vec < Covspan > {
189
+ fn remove_unwanted_overlapping_spans ( sorted_spans : Vec < Covspan > ) -> Vec < Covspan > {
190
+ debug_assert ! ( sorted_spans. is_sorted_by( |a, b| compare_spans( a. span, b. span) . is_le( ) ) ) ;
191
+
184
192
// Holds spans that have been read from the input vector, but haven't yet
185
193
// been committed to the output vector.
186
194
let mut pending = vec ! [ ] ;
@@ -205,12 +213,6 @@ fn refine_sorted_spans(sorted_spans: Vec<Covspan>) -> Vec<Covspan> {
205
213
206
214
// Drain the rest of the pending list into the refined list.
207
215
refined. extend ( pending) ;
208
-
209
- // Do one last merge pass, to simplify the output.
210
- debug ! ( ?refined, "before merge" ) ;
211
- refined. dedup_by ( |b, a| a. merge_if_eligible ( b) ) ;
212
- debug ! ( ?refined, "after merge" ) ;
213
-
214
216
refined
215
217
}
216
218
0 commit comments