-
Notifications
You must be signed in to change notification settings - Fork 12.9k
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
coverage: Fix an unstable-sort inconsistency in coverage spans #115930
Conversation
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.
(rustbot has picked a reviewer for you, use r? to override) |
Some changes occurred to MIR optimizations cc @rust-lang/wg-mir-opt |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
This file shows the inconsistent handling of closure spans caused by this bug.
Some closure signatures were already treated as non-executable, while others were being treated as part of the preceding code, depending on implementation details of the unstable sort.
Switching to `Ordering::then_with` makes control-flow less complicated, and there is no need to use `partial_cmp` here.
@bors r+ |
…iaskrgr Rollup of 8 pull requests Successful merges: - rust-lang#115869 (Avoid blessing cargo deps's source code in ui tests) - rust-lang#115873 (Make `TyKind::Adt`'s `Debug` impl be more pretty) - rust-lang#115879 (Migrate diagnostics in `hir_typeck/src/cast.rs`) - rust-lang#115930 (coverage: Fix an unstable-sort inconsistency in coverage spans) - rust-lang#115931 (Move mobile topbar title creation entirely into JS) - rust-lang#115941 (Add myself to .mailmap) - rust-lang#115943 (compiletest: Don't swallow some error messages.) - rust-lang#115949 (Update browser-ui-test version) r? `@ghost` `@rustbot` modify labels: rollup
Rollup merge of rust-lang#115930 - Zalathar:spans-bug, r=compiler-errors 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 PR 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. --- In addition to the fix itself, this PR also contains a cleanup to the comparison function that I was working on when I discovered the bug.
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 PR 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.
In addition to the fix itself, this PR also contains a cleanup to the comparison function that I was working on when I discovered the bug.