1.81.0 not panic when running incorrect implementations of Ord #130178
Labels
C-discussion
Category: Discussion or questions that doesn't represent real issues.
T-libs
Relevant to the library team, which will review and decide on the PR/issue.
<!--
Thank you for filing a bug report! 🐛 Please provide a short summary of the bug,
along with any information you feel relevant to replicating the bug.
-->
I tried this code by running
rustup run 1.81.0 cargo run
:I expected to see this happen: explanation
The program would panic on the line "vec.sort();" since "the new sort algorithms try to detect incorrect implementations of Ord that prevent them from being able to produce a meaningfully sorted result, and will now panic on such cases rather than returning effectively randomly arranged data.", according to the "New sort implementations" in https://blog.rust-lang.org/2024/09/05/Rust-1.81.0.html.
Instead, this happened: explanation
The program paniced on the line "assert!(BadOrd(1) < BadOrd(2));". Here is the output:
Before sorting: [BadOrd(3), BadOrd(2), BadOrd(4), BadOrd(1)]
After sorting: [BadOrd(2), BadOrd(4), BadOrd(3), BadOrd(1)]
thread 'main' panicked at src/main.rs:53:5:
assertion failed: BadOrd(1) < BadOrd(2)
note: run with
RUST_BACKTRACE=1
environment variable to display a backtraceMeta
rustc --version --verbose
:Backtrace
The text was updated successfully, but these errors were encountered: