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