@@ -315,7 +315,7 @@ impl<'a> CoverageSpansGenerator<'a> {
315315 debug ! (
316316 " curr overlaps a closure (prev). Drop curr and keep prev for next iter. prev={prev:?}" ,
317317 ) ;
318- self . take_curr ( ) ;
318+ self . take_curr ( ) ; // Discards curr.
319319 } else if curr. is_closure {
320320 self . carve_out_span_for_closure ( ) ;
321321 } else if self . prev_original_span == curr. span {
@@ -341,7 +341,7 @@ impl<'a> CoverageSpansGenerator<'a> {
341341 as prev, but is in a different bcb. Drop curr and keep prev for next iter. \
342342 prev={prev:?}",
343343 ) ;
344- self . take_curr ( ) ;
344+ self . take_curr ( ) ; // Discards curr.
345345 } else {
346346 self . hold_pending_dups_unless_dominated ( ) ;
347347 }
@@ -431,6 +431,12 @@ impl<'a> CoverageSpansGenerator<'a> {
431431 . unwrap_or_else ( || bug ! ( "invalid attempt to unwrap a None some_curr" ) )
432432 }
433433
434+ /// If called, then the next call to `next_coverage_span()` will *not* update `prev` with the
435+ /// `curr` coverage span.
436+ fn take_curr ( & mut self ) -> CoverageSpan {
437+ self . some_curr . take ( ) . unwrap_or_else ( || bug ! ( "invalid attempt to unwrap a None some_curr" ) )
438+ }
439+
434440 fn prev ( & self ) -> & CoverageSpan {
435441 self . some_prev
436442 . as_ref ( )
@@ -503,12 +509,6 @@ impl<'a> CoverageSpansGenerator<'a> {
503509 false
504510 }
505511
506- /// If called, then the next call to `next_coverage_span()` will *not* update `prev` with the
507- /// `curr` coverage span.
508- fn take_curr ( & mut self ) -> CoverageSpan {
509- self . some_curr . take ( ) . unwrap_or_else ( || bug ! ( "invalid attempt to unwrap a None some_curr" ) )
510- }
511-
512512 /// Returns true if the curr span should be skipped because prev has already advanced beyond the
513513 /// end of curr. This can only happen if a prior iteration updated `prev` to skip past a region
514514 /// of code, such as skipping past a closure.
@@ -555,7 +555,7 @@ impl<'a> CoverageSpansGenerator<'a> {
555555 dup. span = dup. span . with_lo ( right_cutoff) ;
556556 }
557557 self . pending_dups . append ( & mut pending_dups) ;
558- let closure_covspan = self . take_curr ( ) ;
558+ let closure_covspan = self . take_curr ( ) ; // Prevent this curr from becoming prev.
559559 self . push_refined_span ( closure_covspan) ; // since self.prev() was already updated
560560 } else {
561561 pending_dups. clear ( ) ;
0 commit comments