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

Deriving `zeroize::Zeroize` requires the `Zeroize` trait to already be in scope

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

还没有人认领这个 Issue。

评估

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

调研方向

运行 src/lib.rs 中的最小复现,并检查 zeroize::Zeroize 的 derive 展开,以 serde 的 derive 对比作为上下文。当派生 zeroize::Zeroize 不再要求显式导入 use zeroize::Zeroize,且复现仍能编译时,确认该问题已解决。

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

描述

Hi, while trying to add zeroize support to a crate I'm making, I found that I was getting a weird error about the Zeroize trait not being in scope:

error[E0405]: cannot find trait `Zeroize` in this scope
  --> src\lib.rs:13:40
   |
13 | #[cfg_attr(feature = "zeroize", derive(zeroize::Zeroize))]
   |                                        ^^^^^^^^^^^^^^^^ not found in this scope
   |
   = note: this error originates in the derive macro `zeroize::Zeroize` (in Nightly builds, run with -Z macro-backtrace for more info)
help: consider importing this trait
   |
 3 + use zeroize::Zeroize;
   |

Here's a minimal reproduction (unfortunately I can't send a playground link, since the playground doesn't provide the zeroize derives):

#[derive(zeroize::Zeroize)]
struct A;

The fix is relatively simple:

use zeroize::Zeroize;

#[derive(zeroize::Zeroize)]
struct A;

though having a trait in scope solely for a derive feels... wrong.

I will note that serde is able to derive without its relevant traits in scope:

#[derive(serde::Serialize, serde::Deserialize)]
struct A;

So perhaps zeroize should be changed to do the same?

Thank you for your time, and hopefully this is a relatively easy fix.

主要语言
Rust
星标
674
派生
170
平均合并
1 天 12 小时
30 天内合并 PR
10

贡献指南

这个仓库没有索引到贡献指南

从这里开始

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

RustCrypto/utils 的其他 Issue

查看 RustCrypto/utils 的全部 Issue

相似的 Issue

更多 Rust Issue

把新 issue 发到你的邮箱

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