Skip to content

Commit d73c48b

Browse files
committed
coverage: Flatten guard logic in check_pending_dups
1 parent 43ca95b commit d73c48b

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

0 commit comments

Comments
 (0)