Hacktoberfest 2026:维护者为十月标记出来的 issue,仍然开放、适合新手。 浏览 Hacktoberfest issue

`PartialOrd` doesn't work with new type

未关闭
#409 1 条评论 0 个 reaction 已指派 0 人 在 GitHub 查看

还没有人认领这个 Issue。

评估

难度
4/5
预计耗时
3-5 天
新手友好度
35/100
Issue 类型
缺陷
描述清晰度
基本清楚
活跃度
停滞
技术栈
rust
领域
compilers

调研方向

从 crates/farmer/ab-proof-of-space-gpu/src/shader/sort_buckets.rs 中的复现开始,重点查看第 17 行的 CustomPosition derive 和第 80 行的比较。将为 CustomPosition 生成的 PartialOrd 路径与直接的 u32 比较进行对比,然后检查对不需要的 Int8 capability 的处理;当 newtype 比较无需 Int8 即可编译时,即视为完成。

由索引模型根据 Issue 内容生成。

描述

bug

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.

主要语言
Rust
星标
3.4k
派生
126
PR 合并指标
30 天内没有已合并 PR

贡献指南

打开贡献指南

从这里开始

  1. 先读完整个 Issue,再读项目的贡献指南。
  2. 在 Issue 下留言说明你要接手 —— 这能避免两个人做同样的事。
  3. Fork 仓库,在一个分支上完成修改。
  4. 提交 Pull Request,并在描述里引用这个 Issue 编号。

Rust-GPU/rust-gpu 的其他 Issue

查看 Rust-GPU/rust-gpu 的全部 Issue

相似的 Issue

更多 Rust Issue

把新 issue 发到你的邮箱

精选适合新手参与的 GitHub issue 摘要。