Skip to content

Commit 3055a34

Browse files
committed
coverage: Move take_curr and note what its callers are doing
1 parent 5943fb7 commit 3055a34

File tree

1 file changed

+9
-9
lines changed
  • compiler/rustc_mir_transform/src/coverage

1 file changed

+9
-9
lines changed

compiler/rustc_mir_transform/src/coverage/spans.rs

Lines changed: 9 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -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
}
@@ -428,6 +428,12 @@ impl<'a> CoverageSpansGenerator<'a> {
428428
.unwrap_or_else(|| bug!("invalid attempt to unwrap a None some_curr"))
429429
}
430430

431+
/// If called, then the next call to `next_coverage_span()` will *not* update `prev` with the
432+
/// `curr` coverage span.
433+
fn take_curr(&mut self) -> CoverageSpan {
434+
self.some_curr.take().unwrap_or_else(|| bug!("invalid attempt to unwrap a None some_curr"))
435+
}
436+
431437
fn prev(&self) -> &CoverageSpan {
432438
self.some_prev
433439
.as_ref()
@@ -497,12 +503,6 @@ impl<'a> CoverageSpansGenerator<'a> {
497503
false
498504
}
499505

500-
/// If called, then the next call to `next_coverage_span()` will *not* update `prev` with the
501-
/// `curr` coverage span.
502-
fn take_curr(&mut self) -> CoverageSpan {
503-
self.some_curr.take().unwrap_or_else(|| bug!("invalid attempt to unwrap a None some_curr"))
504-
}
505-
506506
/// Returns true if the curr span should be skipped because prev has already advanced beyond the
507507
/// end of curr. This can only happen if a prior iteration updated `prev` to skip past a region
508508
/// of code, such as skipping past a closure.
@@ -549,7 +549,7 @@ impl<'a> CoverageSpansGenerator<'a> {
549549
dup.span = dup.span.with_lo(right_cutoff);
550550
}
551551
self.pending_dups.append(&mut pending_dups);
552-
let closure_covspan = self.take_curr();
552+
let closure_covspan = self.take_curr(); // Prevent this curr from becoming prev.
553553
self.push_refined_span(closure_covspan); // since self.prev() was already updated
554554
} else {
555555
pending_dups.clear();

0 commit comments

Comments
 (0)