Skip to content

Commit 7bbe4be

Browse files
committed
coverage: Flatten guard logic in maybe_flush_pending_dups
1 parent 97d1a91 commit 7bbe4be

File tree

1 file changed

+16
-15
lines changed
  • compiler/rustc_mir_transform/src/coverage

1 file changed

+16
-15
lines changed

compiler/rustc_mir_transform/src/coverage/spans.rs

Lines changed: 16 additions & 15 deletions
Original file line numberDiff line numberDiff line change
@@ -456,22 +456,23 @@ impl<'a> CoverageSpansGenerator<'a> {
456456
/// In either case, no more spans will match the span of `pending_dups`, so
457457
/// add the `pending_dups` if they don't overlap `curr`, and clear the list.
458458
fn maybe_flush_pending_dups(&mut self) {
459-
if let Some(dup) = self.pending_dups.last()
460-
&& dup.span != self.prev().span
461-
{
462-
debug!(
463-
" SAME spans, but pending_dups are NOT THE SAME, so BCBs matched on \
464-
previous iteration, or prev started a new disjoint span"
465-
);
466-
if dup.span.hi() <= self.curr().span.lo() {
467-
let pending_dups = self.pending_dups.split_off(0);
468-
for dup in pending_dups.into_iter() {
469-
debug!(" ...adding at least one pending={:?}", dup);
470-
self.push_refined_span(dup);
471-
}
472-
} else {
473-
self.pending_dups.clear();
459+
let Some(last_dup) = self.pending_dups.last() else { return };
460+
if last_dup.span == self.prev().span {
461+
return;
462+
}
463+
464+
debug!(
465+
" SAME spans, but pending_dups are NOT THE SAME, so BCBs matched on \
466+
previous iteration, or prev started a new disjoint span"
467+
);
468+
if last_dup.span.hi() <= self.curr().span.lo() {
469+
let pending_dups = self.pending_dups.split_off(0);
470+
for dup in pending_dups.into_iter() {
471+
debug!(" ...adding at least one pending={:?}", dup);
472+
self.push_refined_span(dup);
474473
}
474+
} else {
475+
self.pending_dups.clear();
475476
}
476477
}
477478

0 commit comments

Comments
 (0)