docs

#E0094: 無效的表示法

#[repr(..)] 或 #[niche] 與型別不相符,例如含有受 GC 管理之參考的 packed 結構、repr 不是 C 的聯集,或用在多於一個欄位之型別上的 #[niche]。請修改屬性或型別。

nabi
#[niche]
struct Pair { a: i32; b: i32; }
error[E0094]: `#[niche]` goes on a single-field struct, not a struct with 2 fields
  --> main.nabi:1:1
   |
 1 | #[niche]
   | ^^

把 #[niche] 用在恰好只有一個欄位的結構上,或者移除它。#[repr(packed)] 結構只能容納 C 資料,不能容納 str、集合或閉包。

相關錯誤碼:E0086 無效的聯集、E0083 無效的列舉值

發現錯誤? 在 GitHub 上編輯此頁 最後更新: