Skip to content

Commit 9ac9cf3

Browse files
committed
coverage: Inline prev_starts_after_next
1 parent 3055a34 commit 9ac9cf3

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
@@ -485,11 +485,13 @@ impl<'a> CoverageSpansGenerator<'a> {
485485
}
486486
while let Some(curr) = self.sorted_spans_iter.next() {
487487
debug!("FOR curr={:?}", curr);
488-
if self.some_prev.is_some() && self.prev_starts_after_next(&curr) {
488+
if let Some(prev) = &self.some_prev && prev.span.lo() > curr.span.lo() {
489+
// Skip curr because prev has already advanced beyond the end of curr.
490+
// This can only happen if a prior iteration updated `prev` to skip past
491+
// a region of code, such as skipping past a closure.
489492
debug!(
490493
" prev.span starts after curr.span, so curr will be dropped (skipping past \
491-
closure?); prev={:?}",
492-
self.prev()
494+
closure?); prev={prev:?}",
493495
);
494496
} else {
495497
// Save a copy of the original span for `curr` in case the `CoverageSpan` is changed
@@ -503,13 +505,6 @@ impl<'a> CoverageSpansGenerator<'a> {
503505
false
504506
}
505507

506-
/// Returns true if the curr span should be skipped because prev has already advanced beyond the
507-
/// end of curr. This can only happen if a prior iteration updated `prev` to skip past a region
508-
/// of code, such as skipping past a closure.
509-
fn prev_starts_after_next(&self, next_curr: &CoverageSpan) -> bool {
510-
self.prev().span.lo() > next_curr.span.lo()
511-
}
512-
513508
/// If `prev`s span extends left of the closure (`curr`), carve out the closure's span from
514509
/// `prev`'s span. (The closure's coverage counters will be injected when processing the
515510
/// 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)