-
Notifications
You must be signed in to change notification settings - Fork 13.6k
Closed
Description
I've not found a way to minimal compiler test case, but I do have a repeatable example and video evidence in the form of debugger step-through session.
Code
here's a snippet of the code:
let l = &row_l.placement_state.unit_position.x;
let r = &row_r.placement_state.unit_position.x;
println!("l: {:?}, r: {:?}", l, r);
let ordering1 = l.cmp(r);
println!("ordering1: {:?}", ordering1);
println!("l: {:?}, r: {:?}", &row_l.placement_state.unit_position.x, &row_r.placement_state.unit_position.x);
let ordering2 = row_l
.placement_state
.unit_position
.x
.cmp(&row_r.placement_state.placement.x);
println!("ordering2: {:?}", ordering2);
if ordering1 != ordering2 {
panic!("ordering1: {:?}, ordering2: {:?}", ordering1, ordering2); // <-- the above code causes this panic to execute. if this check is removed, rust 1.81 and onwards will cause a panic since this code is used in `sort_by`.
}
ordering1
this prints out:
l: 114.5, r: 117
ordering1: Less
l: 114.5, r: 117
ordering2: Greater
it should print out:
l: 114.5, r: 117
ordering1: Less
l: 114.5, r: 117
ordering2: Less
The commit with the above is here:
The video walkthough is here:
https://www.youtube.com/watch?v=0bD76RJmrgI
The original bug report against rust_decimal is here, though I do not currently think there's anything wrong with the rust_decimal Ord implementation.
Meta
rustc --version --verbose
:
rustc 1.87.0 (17067e9ac 2025-05-09)
binary: rustc
commit-hash: 17067e9ac6d7ecb70e50f92c1944e545188d2359
commit-date: 2025-05-09
host: x86_64-pc-windows-msvc
release: 1.87.0
LLVM version: 20.1.1
Error output
N/A
Metadata
Metadata
Assignees
Labels
No labels