Open
Description
Related to #84970, I'm filling this because cargo asked nicely :)
Code
Context: this is an excerpt from a roguelike game that uses Legion as its ECS lib. I guess the bug was there, since it's the only place I'm using .partial_cmp()
. It crashed after I added the .sort_by(distance)
part.
// Collect all entities into the player's FOV
let mut entities = <(Entity, &Point, &Renderable, &Name, Option<&CombatStats>)>::query()
.iter(world)
.collect::<Vec<(&Entity, &Point, &Renderable, &Name, Option<&CombatStats>)>>();
// Sort them by distance from the player
entities.sort_by(|&a, &b| {
DistanceAlg::Pythagoras
.distance2d(*a.1, *player_pos)
.partial_cmp(&DistanceAlg::Pythagoras.distance2d(*b.1, *player_pos))
.unwrap_or(Ordering::Equal)
});
Meta
rustc --version --verbose
:
rustc 1.54.0 (a178d0322 2021-07-26)
binary: rustc
commit-hash: a178d0322ce20e33eac124758e837cbd80a6f633
commit-date: 2021-07-26
host: x86_64-pc-windows-msvc
release: 1.54.0
LLVM version: 12.0.1
Error output
thread 'rustc' panicked at 'Found unstable fingerprints for predicates_of(core[460f]::cmp::PartialOrd):
GenericPredicates { parent: None, predicates: [(Binder(TraitPredicate(<Self as std::cmp::PartialEq<Rhs>>), []),
C:\[redacted]\.rustup\toolchains\stable-x86_64-pc-windows-msvc\lib/rustlib/src/rust\library\core\src\cmp.rs:936:43: 936:57
(#80706 (Binder(TraitPredicate(<Self as std::cmp::PartialOrd<Rhs>>), []),
C:\[redacted]\.rustup\toolchains\stable-x86_64-pc-windows-msvc\lib/rustlib/src/rust\library\core\src\cmp.rs:936:1: 1041:2 (#0))] }',
/rustc/a178d0322ce20e33eac124758e837cbd80a6f633\compiler\rustc_query_system\src\query\plumbing.rs:620:9
<sorry no backtrace, I cleaned before that>