File tree Expand file tree Collapse file tree 1 file changed +7
-7
lines changed
compiler/rustc_mir_transform/src/coverage Expand file tree Collapse file tree 1 file changed +7
-7
lines changed Original file line number Diff line number Diff line change @@ -132,11 +132,13 @@ impl PrevCovspan {
132132 self . merged_spans . push ( other. span ) ;
133133 }
134134
135- fn cutoff_statements_at ( & mut self , cutoff_pos : BytePos ) {
135+ fn cutoff_statements_at ( mut self , cutoff_pos : BytePos ) -> Option < RefinedCovspan > {
136136 self . merged_spans . retain ( |span| span. hi ( ) <= cutoff_pos) ;
137137 if let Some ( max_hi) = self . merged_spans . iter ( ) . map ( |span| span. hi ( ) ) . max ( ) {
138138 self . span = self . span . with_hi ( max_hi) ;
139139 }
140+
141+ if self . merged_spans . is_empty ( ) { None } else { Some ( self . into_refined ( ) ) }
140142 }
141143
142144 fn refined_copy ( & self ) -> RefinedCovspan {
@@ -374,13 +376,11 @@ impl SpansRefiner {
374376 ) ;
375377
376378 let curr_span = self . curr ( ) . span ;
377- self . prev_mut ( ) . cutoff_statements_at ( curr_span. lo ( ) ) ;
378- if self . prev ( ) . merged_spans . is_empty ( ) {
379- debug ! ( " ... no non-overlapping statements to add" ) ;
380- } else {
381- debug ! ( " ... adding modified prev={:?}" , self . prev( ) ) ;
382- let prev = self . take_prev ( ) . into_refined ( ) ;
379+ if let Some ( prev) = self . take_prev ( ) . cutoff_statements_at ( curr_span. lo ( ) ) {
380+ debug ! ( "after cutoff, adding {prev:?}" ) ;
383381 self . refined_spans . push ( prev) ;
382+ } else {
383+ debug ! ( "prev was eliminated by cutoff" ) ;
384384 }
385385 }
386386}
You can’t perform that action at this time.
0 commit comments