Hacktoberfest 2026: the issues maintainers tagged for October, open and beginner-friendly. Browse Hacktoberfest issues

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

Open
#1,271 0 comments 0 reactions 0 assignees View on GitHub

Maintainers usually reply within 2 days

Nobody has claimed this yet.

Assessment

Difficulty
3/5
Estimated time
1-2 days
Newbie friendliness
45/100
Issue type
Bug
Clarity
Mostly clear
Activity status
Stale
Tech stack
rust
Domain
tooling

Research direction

Run the minimal reproduction in src/lib.rs and inspect the zeroize::Zeroize derive expansion, using the serde derive comparison as context. Confirm the issue is resolved when deriving zeroize::Zeroize no longer requires an explicit use zeroize::Zeroize import, while the reproduction still compiles.

Written by the indexing model from the issue text.

Description

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.

Dominant language
Rust
Stars
674
Forks
170
Avg merge
1d 12h
Merged PRs (30d)
10

Getting set up

We have not checked this project's setup files yet. Start from its README, and see our first-contribution guide for the general steps.

First steps

  1. Read the whole issue, then the project's contributing guide.
  2. Comment on the issue to say you are picking it up — it saves two people doing the same work.
  3. Fork the repository and make your change on a branch.
  4. Open a pull request that references the issue number.

More from RustCrypto/utils

All issues in RustCrypto/utils

Similar issues

More Rust issues

Get new issues in your inbox

A short digest of beginner-friendly GitHub issues.