1
- use rustc_data_structures:: captures:: Captures ;
2
1
use rustc_data_structures:: fx:: FxHashSet ;
3
2
use rustc_middle:: bug;
4
3
use rustc_middle:: mir:: coverage:: CoverageKind ;
@@ -29,7 +28,7 @@ pub(super) fn mir_to_initial_sorted_coverage_spans(
29
28
let mut initial_spans = vec ! [ ] ;
30
29
31
30
for ( bcb, bcb_data) in basic_coverage_blocks. iter_enumerated ( ) {
32
- initial_spans . extend ( bcb_to_initial_coverage_spans ( mir_body, body_span, bcb, bcb_data) ) ;
31
+ bcb_to_initial_coverage_spans ( mir_body, body_span, bcb, bcb_data, & mut initial_spans ) ;
33
32
}
34
33
35
34
// Only add the signature span if we found at least one span in the body.
@@ -135,8 +134,9 @@ fn bcb_to_initial_coverage_spans<'a, 'tcx>(
135
134
body_span : Span ,
136
135
bcb : BasicCoverageBlock ,
137
136
bcb_data : & ' a BasicCoverageBlockData ,
138
- ) -> impl Iterator < Item = SpanFromMir > + Captures < ' a > + Captures < ' tcx > {
139
- bcb_data. basic_blocks . iter ( ) . flat_map ( move |& bb| {
137
+ initial_covspans : & mut Vec < SpanFromMir > ,
138
+ ) {
139
+ for & bb in & bcb_data. basic_blocks {
140
140
let data = & mir_body[ bb] ;
141
141
142
142
let unexpand = move |expn_span| {
@@ -146,24 +146,27 @@ fn bcb_to_initial_coverage_spans<'a, 'tcx>(
146
146
. filter ( |( span, _) | !span. source_equal ( body_span) )
147
147
} ;
148
148
149
- let statement_spans = data. statements . iter ( ) . filter_map ( move |statement| {
150
- let expn_span = filtered_statement_span ( statement) ?;
151
- let ( span, visible_macro) = unexpand ( expn_span) ?;
152
-
153
- // A statement that looks like the assignment of a closure expression
154
- // is treated as a "hole" span, to be carved out of other spans.
155
- Some ( SpanFromMir :: new ( span, visible_macro, bcb, is_closure_like ( statement) ) )
156
- } ) ;
149
+ for statement in data. statements . iter ( ) {
150
+ let _: Option < ( ) > = try {
151
+ let expn_span = filtered_statement_span ( statement) ?;
152
+ let ( span, visible_macro) = unexpand ( expn_span) ?;
153
+
154
+ // A statement that looks like the assignment of a closure expression
155
+ // is treated as a "hole" span, to be carved out of other spans.
156
+ let covspan =
157
+ SpanFromMir :: new ( span, visible_macro, bcb, is_closure_like ( statement) ) ;
158
+ initial_covspans. push ( covspan) ;
159
+ } ;
160
+ }
157
161
158
- let terminator_span = Some ( data. terminator ( ) ) . into_iter ( ) . filter_map ( move |terminator| {
162
+ let _: Option < ( ) > = try {
163
+ let terminator = data. terminator ( ) ;
159
164
let expn_span = filtered_terminator_span ( terminator) ?;
160
165
let ( span, visible_macro) = unexpand ( expn_span) ?;
161
166
162
- Some ( SpanFromMir :: new ( span, visible_macro, bcb, false ) )
163
- } ) ;
164
-
165
- statement_spans. chain ( terminator_span)
166
- } )
167
+ initial_covspans. push ( SpanFromMir :: new ( span, visible_macro, bcb, false ) ) ;
168
+ } ;
169
+ }
167
170
}
168
171
169
172
fn is_closure_like ( statement : & Statement < ' _ > ) -> bool {
0 commit comments