`PartialOrd` doesn't work with new type
オープン
まだ誰も着手していません。
bug
- 主要言語
- Rust
- スター
- 3.4k
- フォーク
- 126
- PR マージ指標
- 30日以内にマージされた PR はありません
説明
I have the following trivial new type:
#[derive(Debug, Clone, Copy, Ord, PartialOrd, Eq, PartialEq, From, Into)]
pub struct CustomPosition(u32);
When trying to compare two values of this type, I'm getting an error:
error: `i8` type used without `OpCapability Int8`
|
note: used from within `<u32 as core::cmp::PartialOrd>::partial_cmp`
--> /home/nazar-pc/.rustup/toolchains/nightly-2025-06-23-x86_64-unknown-linux-gnu/lib/rustlib/src/rust/library/core/src/cmp.rs:1989:5
|
1989 | ord_impl! { char usize u8 u16 u32 u64 u128 isize i8 i16 i32 i64 i128 }
| ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
note: called by `<ab_proof_of_space_gpu::shader::sort_buckets::CustomPosition as core::cmp::PartialOrd>::partial_cmp`
--> crates/farmer/ab-proof-of-space-gpu/src/shader/sort_buckets.rs:17:35
|
17 | #[derive(Debug, Clone, Copy, Ord, PartialOrd, Eq, PartialEq, From, Into)]
| ^^^^^^^^^^
note: called by `<ab_proof_of_space_gpu::shader::sort_buckets::CustomPosition as core::cmp::PartialOrd>::le`
--> /home/nazar-pc/.rustup/toolchains/nightly-2025-06-23-x86_64-unknown-linux-gnu/lib/rustlib/src/rust/library/core/src/cmp.rs:1403:14
|
1403 | self.partial_cmp(other).is_some_and(Ordering::is_le)
| ^^^^^^^^^^^^^^^^^^
note: called by `ab_proof_of_space_gpu::shader::sort_buckets::perform_compare_swap`
--> crates/farmer/ab-proof-of-space-gpu/src/shader/sort_buckets.rs:80:32
|
80 | let (smaller, larger) = if a <= b { (a, b) } else { (b, a) };
| ^^^^^^
At the same time, comparison of u32 directly works fine and doesn't require Int8 capability.
While this is likely related to discussion in https://github.com/Rust-GPU/rust-gpu/issues/307, I think it is distinct enough to be reported separately.
コントリビューションガイド
はじめの一歩
- issue を最後まで読み、次にプロジェクトのコントリビューションガイドを読みます。
- 着手することを issue にコメントします — 二人が同じ作業をするのを防げます。
- リポジトリをフォークし、ブランチを切って変更します。
- issue 番号を参照したプルリクエストを送ります。
調査の方向性
crates/farmer/ab-proof-of-space-gpu/src/shader/sort_buckets.rs の再現から始め、特に 17 行目の CustomPosition derive と 80 行目の比較を確認します。CustomPosition に対して生成される PartialOrd の経路を u32 の直接比較と比較し、その後、不要な Int8 capability の扱いを調べます。newtype の比較が Int8 を要求せずにコンパイルできれば完了です。
索引モデルが issue の本文から書いたものです。
評価
- 技術スタック
- rust
- 領域
- compilers
- issue の種類
- バグ
- 難易度
- 4/5
- 見積もり時間
- 3〜5日
- 活発さ
- 停滞
- 明瞭さ
- おおむね明確
- 初心者へのやさしさ
- 35/100