diff options
| author | Zalathar <Zalathar@users.noreply.github.com> | 2023-10-14 22:15:18 +1100 |
|---|---|---|
| committer | Zalathar <Zalathar@users.noreply.github.com> | 2023-10-16 21:05:46 +1100 |
| commit | 4ab4273d6425e69d0d4652d15f84adbc00f093bd (patch) | |
| tree | f1a02607fdd2211ff5ac90835e6d89dbb57a5e37 /compiler/rustc_mir_transform/src/coverage | |
| parent | 25e63032020a2bb97a00ff4db3e0be6a1b7494df (diff) | |
| download | rust-4ab4273d6425e69d0d4652d15f84adbc00f093bd.tar.gz rust-4ab4273d6425e69d0d4652d15f84adbc00f093bd.zip | |
coverage: Inline `prev_starts_after_next`
Diffstat (limited to 'compiler/rustc_mir_transform/src/coverage')
| -rw-r--r-- | compiler/rustc_mir_transform/src/coverage/spans.rs | 15 |
1 files changed, 5 insertions, 10 deletions
diff --git a/compiler/rustc_mir_transform/src/coverage/spans.rs b/compiler/rustc_mir_transform/src/coverage/spans.rs index 63d2a2eeaeb..66d49bd33db 100644 --- a/compiler/rustc_mir_transform/src/coverage/spans.rs +++ b/compiler/rustc_mir_transform/src/coverage/spans.rs @@ -492,11 +492,13 @@ impl<'a> CoverageSpansGenerator<'a> { } while let Some(curr) = self.sorted_spans_iter.next() { debug!("FOR curr={:?}", curr); - if self.some_prev.is_some() && self.prev_starts_after_next(&curr) { + if let Some(prev) = &self.some_prev && prev.span.lo() > curr.span.lo() { + // Skip curr because prev has already advanced beyond the end of curr. + // This can only happen if a prior iteration updated `prev` to skip past + // a region of code, such as skipping past a closure. debug!( " prev.span starts after curr.span, so curr will be dropped (skipping past \ - closure?); prev={:?}", - self.prev() + closure?); prev={prev:?}", ); } else { // Save a copy of the original span for `curr` in case the `CoverageSpan` is changed @@ -510,13 +512,6 @@ impl<'a> CoverageSpansGenerator<'a> { false } - /// Returns true if the curr span should be skipped because prev has already advanced beyond the - /// end of curr. This can only happen if a prior iteration updated `prev` to skip past a region - /// of code, such as skipping past a closure. - fn prev_starts_after_next(&self, next_curr: &CoverageSpan) -> bool { - self.prev().span.lo() > next_curr.span.lo() - } - /// If `prev`s span extends left of the closure (`curr`), carve out the closure's span from /// `prev`'s span. (The closure's coverage counters will be injected when processing the /// closure's own MIR.) Add the portion of the span to the left of the closure; and if the span |
