Skip to content

Commit f87d863

Browse files
committed
coverage: Flatten guard logic in maybe_flush_pending_dups
1 parent 0c4e533 commit f87d863

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

0 commit comments

Comments
 (0)