@@ -314,7 +314,7 @@ impl<'a> CoverageSpansGenerator<'a> {
314314 debug ! (
315315 " curr overlaps a closure (prev). Drop curr and keep prev for next iter. prev={prev:?}" ,
316316 ) ;
317- self . take_curr ( ) ;
317+ self . take_curr ( ) ; // Discards curr.
318318 } else if curr. is_closure {
319319 self . carve_out_span_for_closure ( ) ;
320320 } else if self . prev_original_span == curr. span {
@@ -340,7 +340,7 @@ impl<'a> CoverageSpansGenerator<'a> {
340340 as prev, but is in a different bcb. Drop curr and keep prev for next iter. \
341341 prev={prev:?}",
342342 ) ;
343- self . take_curr ( ) ;
343+ self . take_curr ( ) ; // Discards curr.
344344 } else {
345345 self . hold_pending_dups_unless_dominated ( ) ;
346346 }
@@ -430,6 +430,12 @@ impl<'a> CoverageSpansGenerator<'a> {
430430 . unwrap_or_else ( || bug ! ( "invalid attempt to unwrap a None some_curr" ) )
431431 }
432432
433+ /// If called, then the next call to `next_coverage_span()` will *not* update `prev` with the
434+ /// `curr` coverage span.
435+ fn take_curr ( & mut self ) -> CoverageSpan {
436+ self . some_curr . take ( ) . unwrap_or_else ( || bug ! ( "invalid attempt to unwrap a None some_curr" ) )
437+ }
438+
433439 fn prev ( & self ) -> & CoverageSpan {
434440 self . some_prev
435441 . as_ref ( )
@@ -499,12 +505,6 @@ impl<'a> CoverageSpansGenerator<'a> {
499505 false
500506 }
501507
502- /// If called, then the next call to `next_coverage_span()` will *not* update `prev` with the
503- /// `curr` coverage span.
504- fn take_curr ( & mut self ) -> CoverageSpan {
505- self . some_curr . take ( ) . unwrap_or_else ( || bug ! ( "invalid attempt to unwrap a None some_curr" ) )
506- }
507-
508508 /// Returns true if the curr span should be skipped because prev has already advanced beyond the
509509 /// end of curr. This can only happen if a prior iteration updated `prev` to skip past a region
510510 /// of code, such as skipping past a closure.
@@ -551,7 +551,7 @@ impl<'a> CoverageSpansGenerator<'a> {
551551 dup. span = dup. span . with_lo ( right_cutoff) ;
552552 }
553553 self . pending_dups . append ( & mut pending_dups) ;
554- let closure_covspan = self . take_curr ( ) ;
554+ let closure_covspan = self . take_curr ( ) ; // Prevent this curr from becoming prev.
555555 self . push_refined_span ( closure_covspan) ; // since self.prev() was already updated
556556 } else {
557557 pending_dups. clear ( ) ;
0 commit comments