docs

#E0094: 无效的表示

#[repr(..)] 或 #[niche] 与类型不符:持有受垃圾回收管理的引用的 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 上编辑此页 最后更新: