@@ -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 . update_pending_dups ( ) ;
347347 }
@@ -433,6 +433,12 @@ impl<'a> CoverageSpansGenerator<'a> {
433433 . unwrap_or_else ( || bug ! ( "invalid attempt to unwrap a None some_curr" ) )
434434 }
435435
436+ /// If called, then the next call to `next_coverage_span()` will *not* update `prev` with the
437+ /// `curr` coverage span.
438+ fn take_curr ( & mut self ) -> CoverageSpan {
439+ self . some_curr . take ( ) . unwrap_or_else ( || bug ! ( "invalid attempt to unwrap a None some_curr" ) )
440+ }
441+
436442 fn prev ( & self ) -> & CoverageSpan {
437443 self . some_prev
438444 . as_ref ( )
@@ -505,12 +511,6 @@ impl<'a> CoverageSpansGenerator<'a> {
505511 false
506512 }
507513
508- /// If called, then the next call to `next_coverage_span()` will *not* update `prev` with the
509- /// `curr` coverage span.
510- fn take_curr ( & mut self ) -> CoverageSpan {
511- self . some_curr . take ( ) . unwrap_or_else ( || bug ! ( "invalid attempt to unwrap a None some_curr" ) )
512- }
513-
514514 /// Returns true if the curr span should be skipped because prev has already advanced beyond the
515515 /// end of curr. This can only happen if a prior iteration updated `prev` to skip past a region
516516 /// of code, such as skipping past a closure.
@@ -557,7 +557,7 @@ impl<'a> CoverageSpansGenerator<'a> {
557557 dup. span = dup. span . with_lo ( right_cutoff) ;
558558 }
559559 self . pending_dups . append ( & mut pending_dups) ;
560- let closure_covspan = self . take_curr ( ) ;
560+ let closure_covspan = self . take_curr ( ) ; // Prevent this curr from becoming prev.
561561 self . push_refined_span ( closure_covspan) ; // since self.prev() was already updated
562562 } else {
563563 pending_dups. clear ( ) ;
0 commit comments