cpubits: single 16 => { ... } macro arm fails expansion with error: no rules expected ','

未关闭 适合新手
#1,597 0 条评论 0 个 reaction 已指派 0 人 在 GitHub 查看

维护者通常 1 天内回复

还没有人认领这个 Issue。

评估

难度
2/5
预计耗时
1-3 小时
新手友好度
82/100
Issue 类型
缺陷
描述清晰度
描述清楚
活跃度
活跃
技术栈
rust
领域
backend

调研方向

首先找到 crate cpubits 中宏 cpubits! 的定义,并将 16 => { ... } 的展开路径与可正常工作的单分支形式 32 和 64 进行比较。首先要编译的是 issue 中的复现用例;当它能够编译,且列出的可正常工作形式仍能编译时,任务就算完成。

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

描述

Component

cpubits (v0.1.1)

Description

Calling the cpubits! macro with only the 16-bit branch (single 16) fails to expand at compile time with a syntax error. Other single-branch forms (32 => { ... } and 64 => { ... }), pairs, and the full triple compile as expected.

Minimal Reproduction Example
use cpubits::cpubits;

cpubits! {
    16 => {
        pub type Word = u16;
    }
}

fn main() {}
Compiler Output
error: no rules expected `,`
 --> src/main.rs:3:1
  |
3 | / cpubits! {
4 | |     16 => {
5 | |         pub type Word = u16;
6 | |     }
7 | | }
  | |_^ no rules expected this token in macro call
  |
  = note: this error originates in the macro `cpubits::cpubits`
Root Cause

During macro expansion of the single 16 => { ... } pattern, the macro inserts a comma after its first generated branch, but the internal two-branch/downstream matcher in cpubits! does not accept a comma at that position.

Observed shapes probe results:

  • single16: ❌ exit 1 (error: no rules expected ',')
  • single32: ✅ exit 0
  • single64: ✅ exit 0
  • group16_32: ✅ exit 0
  • group32_64: ✅ exit 0
  • pair16_32: ✅ exit 0
  • pair32_64: ✅ exit 0
  • triple: ✅ exit 0
主要语言
Rust
星标
688
派生
177
平均合并
2 小时 31 分钟
30 天内合并 PR
31

环境准备

这个项目没有提供开发容器、Dockerfile 或贡献指南,环境需要你自己搭建:先看它的 README,通用步骤见我们的新手贡献指南。

从这里开始

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

RustCrypto/utils 的其他 Issue

查看 RustCrypto/utils 的全部 Issue

相似的 Issue

更多 Rust Issue

把新 issue 发到你的邮箱

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