1
Fork 0

coverage: Fix an unstable-sort inconsistency in coverage spans

This code was calling `sort_unstable_by`, but failed to impose a total order on
the initial spans. That resulted in unpredictable handling of closure spans,
producing inconsistencies in the coverage maps and in user-visible coverage
reports.

This patch fixes the problem by always sorting closure spans before
otherwise-identical non-closure spans, and also switches to a stable sort in
case the ordering is still not total.
This commit is contained in:
Zalathar 2023-09-18 21:11:14 +10:00
parent 078eb1120a
commit 4690f97099
4 changed files with 20 additions and 17 deletions

View file

@ -76,8 +76,8 @@
LL| 1| some_string = None;
LL| 1| let
LL| 1| a
LL| 1| =
LL| 1| ||
LL| | =
LL| | ||
LL| 1| {
LL| 1| let mut countdown = 0;
LL| 1| if is_false {
@ -98,8 +98,8 @@
LL| 1|
LL| 1| let
LL| 1| quote_closure
LL| 1| =
LL| 1| |val|
LL| | =
LL| | |val|
LL| 5| {
LL| 5| let mut countdown = 0;
LL| 5| if is_false {
@ -186,7 +186,7 @@
LL| | ;
LL| |
LL| 1| let short_used_not_covered_closure_line_break_block_embedded_branch =
LL| 1| | _unused_arg: u8 |
LL| | | _unused_arg: u8 |
LL| 0| {
LL| 0| println!(
LL| 0| "not called: {}",
@ -196,7 +196,7 @@
LL| | ;
LL| |
LL| 1| let short_used_covered_closure_line_break_no_block_embedded_branch =
LL| 1| | _unused_arg: u8 |
LL| | | _unused_arg: u8 |
LL| 1| println!(
LL| 1| "not called: {}",
LL| 1| if is_true { "check" } else { "me" }
@ -205,7 +205,7 @@
LL| | ;
LL| |
LL| 1| let short_used_covered_closure_line_break_block_embedded_branch =
LL| 1| | _unused_arg: u8 |
LL| | | _unused_arg: u8 |
LL| 1| {
LL| 1| println!(
LL| 1| "not called: {}",