Skip to content

Commit 4ab4273

Browse files
committed
coverage: Inline prev_starts_after_next
1 parent 25e6303 commit 4ab4273

File tree

1 file changed

+5
-10
lines changed
  • compiler/rustc_mir_transform/src/coverage

1 file changed

+5
-10
lines changed

compiler/rustc_mir_transform/src/coverage/spans.rs

Lines changed: 5 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -492,11 +492,13 @@ impl<'a> CoverageSpansGenerator<'a> {
492492
}
493493
while let Some(curr) = self.sorted_spans_iter.next() {
494494
debug!("FOR curr={:?}", curr);
495-
if self.some_prev.is_some() && self.prev_starts_after_next(&curr) {
495+
if let Some(prev) = &self.some_prev && prev.span.lo() > curr.span.lo() {
496+
// Skip curr because prev has already advanced beyond the end of curr.
497+
// This can only happen if a prior iteration updated `prev` to skip past
498+
// a region of code, such as skipping past a closure.
496499
debug!(
497500
" prev.span starts after curr.span, so curr will be dropped (skipping past \
498-
closure?); prev={:?}",
499-
self.prev()
501+
closure?); prev={prev:?}",
500502
);
501503
} else {
502504
// Save a copy of the original span for `curr` in case the `CoverageSpan` is changed
@@ -510,13 +512,6 @@ impl<'a> CoverageSpansGenerator<'a> {
510512
false
511513
}
512514

513-
/// Returns true if the curr span should be skipped because prev has already advanced beyond the
514-
/// end of curr. This can only happen if a prior iteration updated `prev` to skip past a region
515-
/// of code, such as skipping past a closure.
516-
fn prev_starts_after_next(&self, next_curr: &CoverageSpan) -> bool {
517-
self.prev().span.lo() > next_curr.span.lo()
518-
}
519-
520515
/// If `prev`s span extends left of the closure (`curr`), carve out the closure's span from
521516
/// `prev`'s span. (The closure's coverage counters will be injected when processing the
522517
/// closure's own MIR.) Add the portion of the span to the left of the closure; and if the span

0 commit comments

Comments
 (0)