@@ -31,7 +31,7 @@ pub(super) fn mir_to_initial_sorted_coverage_spans(
31
31
) -> Vec < Vec < SpanFromMir > > {
32
32
let & ExtractedHirInfo { body_span, .. } = hir_info;
33
33
34
- let mut initial_spans = vec ! [ ] ;
34
+ let mut covspans = vec ! [ ] ;
35
35
let mut holes = vec ! [ ] ;
36
36
37
37
for ( bcb, bcb_data) in basic_coverage_blocks. iter_enumerated ( ) {
@@ -40,36 +40,36 @@ pub(super) fn mir_to_initial_sorted_coverage_spans(
40
40
body_span,
41
41
bcb,
42
42
bcb_data,
43
- & mut initial_spans ,
43
+ & mut covspans ,
44
44
& mut holes,
45
45
) ;
46
46
}
47
47
48
48
// Only add the signature span if we found at least one span in the body.
49
- if !initial_spans . is_empty ( ) || !holes. is_empty ( ) {
49
+ if !covspans . is_empty ( ) || !holes. is_empty ( ) {
50
50
// If there is no usable signature span, add a fake one (before refinement)
51
51
// to avoid an ugly gap between the body start and the first real span.
52
52
// FIXME: Find a more principled way to solve this problem.
53
53
let fn_sig_span = hir_info. fn_sig_span_extended . unwrap_or_else ( || body_span. shrink_to_lo ( ) ) ;
54
- initial_spans . push ( SpanFromMir :: for_fn_sig ( fn_sig_span) ) ;
54
+ covspans . push ( SpanFromMir :: for_fn_sig ( fn_sig_span) ) ;
55
55
}
56
56
57
- initial_spans . sort_by ( |a, b| basic_coverage_blocks. cmp_in_dominator_order ( a. bcb , b. bcb ) ) ;
58
- remove_unwanted_macro_spans ( & mut initial_spans ) ;
59
- split_visible_macro_spans ( & mut initial_spans ) ;
57
+ covspans . sort_by ( |a, b| basic_coverage_blocks. cmp_in_dominator_order ( a. bcb , b. bcb ) ) ;
58
+ remove_unwanted_macro_spans ( & mut covspans ) ;
59
+ split_visible_macro_spans ( & mut covspans ) ;
60
60
61
61
let compare_covspans = |a : & SpanFromMir , b : & SpanFromMir | {
62
62
compare_spans ( a. span , b. span )
63
63
// After deduplication, we want to keep only the most-dominated BCB.
64
64
. then_with ( || basic_coverage_blocks. cmp_in_dominator_order ( a. bcb , b. bcb ) . reverse ( ) )
65
65
} ;
66
- initial_spans . sort_by ( compare_covspans) ;
66
+ covspans . sort_by ( compare_covspans) ;
67
67
68
68
// Among covspans with the same span, keep only one,
69
69
// preferring the one with the most-dominated BCB.
70
70
// (Ideally we should try to preserve _all_ non-dominating BCBs, but that
71
71
// requires a lot more complexity in the span refiner, for little benefit.)
72
- initial_spans . dedup_by ( |b, a| a. span . source_equal ( b. span ) ) ;
72
+ covspans . dedup_by ( |b, a| a. span . source_equal ( b. span ) ) ;
73
73
74
74
// Sort the holes, and merge overlapping/adjacent holes.
75
75
holes. sort_by ( |a, b| compare_spans ( a. span , b. span ) ) ;
@@ -78,7 +78,7 @@ pub(super) fn mir_to_initial_sorted_coverage_spans(
78
78
// Now we're ready to start carving holes out of the initial coverage spans,
79
79
// and grouping them in buckets separated by the holes.
80
80
81
- let mut initial_spans = VecDeque :: from ( initial_spans ) ;
81
+ let mut input_covspans = VecDeque :: from ( covspans ) ;
82
82
let mut fragments: Vec < SpanFromMir > = vec ! [ ] ;
83
83
84
84
// For each hole:
@@ -93,10 +93,10 @@ pub(super) fn mir_to_initial_sorted_coverage_spans(
93
93
// Only inspect spans that precede or overlap this hole,
94
94
// leaving the rest to be inspected by later holes.
95
95
// (This relies on the spans and holes both being sorted.)
96
- let relevant_initial_spans =
97
- drain_front_while ( & mut initial_spans , |c| c. span . lo ( ) < hole. span . hi ( ) ) ;
96
+ let relevant_input_covspans =
97
+ drain_front_while ( & mut input_covspans , |c| c. span . lo ( ) < hole. span . hi ( ) ) ;
98
98
99
- for covspan in fragments_from_prev. into_iter ( ) . chain ( relevant_initial_spans ) {
99
+ for covspan in fragments_from_prev. into_iter ( ) . chain ( relevant_input_covspans ) {
100
100
let ( before, after) = covspan. split_around_hole_span ( hole. span ) ;
101
101
bucket. extend ( before) ;
102
102
fragments. extend ( after) ;
@@ -106,12 +106,12 @@ pub(super) fn mir_to_initial_sorted_coverage_spans(
106
106
// After finding the spans before each hole, any remaining fragments/spans
107
107
// form their own final bucket, after the final hole.
108
108
// (If there were no holes, this will just be all of the initial spans.)
109
- fragments. extend ( initial_spans ) ;
109
+ fragments. extend ( input_covspans ) ;
110
110
buckets. push ( fragments) ;
111
111
112
112
// Make sure each individual bucket is still internally sorted.
113
- for bucket in & mut buckets {
114
- bucket . sort_by ( compare_covspans) ;
113
+ for covspans in & mut buckets {
114
+ covspans . sort_by ( compare_covspans) ;
115
115
}
116
116
buckets
117
117
}
@@ -143,9 +143,9 @@ fn drain_front_while<'a, T>(
143
143
///
144
144
/// (The input spans should be sorted in BCB dominator order, so that the
145
145
/// retained "first" span is likely to dominate the others.)
146
- fn remove_unwanted_macro_spans ( initial_spans : & mut Vec < SpanFromMir > ) {
146
+ fn remove_unwanted_macro_spans ( covspans : & mut Vec < SpanFromMir > ) {
147
147
let mut seen_macro_spans = FxHashSet :: default ( ) ;
148
- initial_spans . retain ( |covspan| {
148
+ covspans . retain ( |covspan| {
149
149
// Ignore (retain) non-macro-expansion spans.
150
150
if covspan. visible_macro . is_none ( ) {
151
151
return true ;
@@ -160,10 +160,10 @@ fn remove_unwanted_macro_spans(initial_spans: &mut Vec<SpanFromMir>) {
160
160
/// function body, split it into two parts. The first part covers just the
161
161
/// macro name plus `!`, and the second part covers the rest of the macro
162
162
/// invocation. This seems to give better results for code that uses macros.
163
- fn split_visible_macro_spans ( initial_spans : & mut Vec < SpanFromMir > ) {
163
+ fn split_visible_macro_spans ( covspans : & mut Vec < SpanFromMir > ) {
164
164
let mut extra_spans = vec ! [ ] ;
165
165
166
- initial_spans . retain ( |covspan| {
166
+ covspans . retain ( |covspan| {
167
167
let Some ( visible_macro) = covspan. visible_macro else { return true } ;
168
168
169
169
let split_len = visible_macro. as_str ( ) . len ( ) as u32 + 1 ;
@@ -183,7 +183,7 @@ fn split_visible_macro_spans(initial_spans: &mut Vec<SpanFromMir>) {
183
183
184
184
// The newly-split spans are added at the end, so any previous sorting
185
185
// is not preserved.
186
- initial_spans . extend ( extra_spans) ;
186
+ covspans . extend ( extra_spans) ;
187
187
}
188
188
189
189
// Generate a set of coverage spans from the filtered set of `Statement`s and `Terminator`s of
0 commit comments