Skip to content

Use float total_cmp instead of partial_cmp to get a total order.#2651

Merged
hecrj merged 1 commit intoiced-rs:masterfrom
rhogenson:total-cmp
Oct 28, 2024
Merged

Use float total_cmp instead of partial_cmp to get a total order.#2651
hecrj merged 1 commit intoiced-rs:masterfrom
rhogenson:total-cmp

Conversation

@rhogenson
Copy link

@rhogenson rhogenson commented Oct 26, 2024

Since Rust version 1.81, sort_by will panic if the provided comparison function does not implement a total order.
See rust-lang/rust#129561 for more details. Fixes #2650, and potentially addresses pop-os/cosmic-epoch#1016

I ran cargo test and cargo clippy

Since Rust version 1.81, sort_by will panic if the provided comparison
function does not implement a total order.
See https://github.com/rust/lang/rust/issues/129561 for more details.
The simplest fix seems to be to use total_cmp instead of partial_cmp.
@hecrj hecrj added this to the 0.14 milestone Oct 28, 2024
@hecrj hecrj added bug Something isn't working rendering fix labels Oct 28, 2024
Copy link
Member

@hecrj hecrj left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Thanks!

@hecrj hecrj enabled auto-merge October 28, 2024 16:31
@hecrj hecrj merged commit 50340b4 into iced-rs:master Oct 28, 2024
mmaechtel added a commit to mmaechtel/X-Addon-Oxide that referenced this pull request Feb 23, 2026
Backport of iced-rs/iced#2651 (merged into iced 0.14).

Since Rust 1.81, sort_by() panics when the comparator violates total
ordering. iced_graphics 0.13's damage::group() uses partial_cmp() on
f32 distances with unwrap_or(Equal), which breaks transitivity when
NaN values appear. This crashes the app on the tiny_skia fallback
renderer path (GL backend / Wayland dmabuf failures).

Fix: replace partial_cmp().unwrap_or(Equal) with total_cmp() in
patches/iced_graphics/src/damage.rs (line 53-55). This is the exact
same fix as upstream PR #2651.

The patched crate is vendored under patches/iced_graphics/ and
referenced via [patch.crates-io] in the workspace Cargo.toml.
Remove this patch when upgrading to iced 0.14+.

Co-Authored-By: Claude Opus 4.6 <noreply@anthropic.com>
mmaechtel added a commit to mmaechtel/X-Addon-Oxide that referenced this pull request Feb 23, 2026
Backport of iced-rs/iced#2651 (merged into iced 0.14).

Since Rust 1.81, sort_by() panics when the comparator violates total
ordering. iced_graphics 0.13's damage::group() uses partial_cmp() on
f32 distances with unwrap_or(Equal), which breaks transitivity when
NaN values appear. This crashes the app on the tiny_skia fallback
renderer path (GL backend / Wayland dmabuf failures).

Fix: replace partial_cmp().unwrap_or(Equal) with total_cmp() in
patches/iced_graphics/src/damage.rs (line 53-55). This is the exact
same fix as upstream PR #2651.

The patched crate is vendored under patches/iced_graphics/ and
referenced via [patch.crates-io] in the workspace Cargo.toml.
Remove this patch when upgrading to iced 0.14+.

Co-Authored-By: Claude Opus 4.6 <noreply@anthropic.com>
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

bug Something isn't working fix rendering

Projects

None yet

Development

Successfully merging this pull request may close these issues.

Panic in cosmic-launcher

2 participants