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 摘要。