Hacktoberfest 2026: những issue maintainer đã đánh dấu cho tháng Mười, đang mở và phù hợp người mới. Xem issue Hacktoberfest

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

Đang mở
#1,271 0 bình luận 0 reaction 0 người được giao Xem trên GitHub

Maintainer thường phản hồi trong vòng 2 ngày

Chưa có ai nhận issue này.

Đánh giá

Độ khó
3/5
Thời gian dự kiến
1-2 ngày
Mức phù hợp với người mới
45/100
Loại issue
Lỗi
Độ rõ ràng
Khá rõ ràng
Mức độ hoạt động
Đình trệ
Công nghệ
rust
Lĩnh vực
tooling

Hướng nghiên cứu

Chạy bản tái hiện tối thiểu trong src/lib.rs và kiểm tra phần mở rộng derive của zeroize::Zeroize, sử dụng so sánh derive của serde làm ngữ cảnh. Xác nhận rằng vấn đề đã được giải quyết khi việc derive zeroize::Zeroize không còn yêu cầu import use zeroize::Zeroize rõ ràng, trong khi bản tái hiện vẫn biên dịch được.

Do mô hình lập chỉ mục viết ra từ nội dung của issue.

Mô tả

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.

Ngôn ngữ chính
Rust
Star
674
Fork
170
Merge trung bình
1 ngày 12 giờ
Pull request đã merge (30 ngày)
10

Chuẩn bị môi trường

Chúng tôi chưa kiểm tra các tệp thiết lập môi trường của dự án này. Hãy bắt đầu từ README và xem hướng dẫn đóng góp lần đầu của chúng tôi để biết các bước chung.

Bắt đầu từ đâu

  1. Đọc hết issue, rồi đọc hướng dẫn đóng góp của dự án.
  2. Bình luận trên issue rằng bạn sẽ nhận — tránh hai người làm cùng một việc.
  3. Fork repository và làm thay đổi trên một nhánh.
  4. Mở pull request có tham chiếu số hiệu của issue.

Issue khác của RustCrypto/utils

Tất cả issue của RustCrypto/utils

Issue tương tự

Thêm issue về Rust

Nhận issue mới trong hộp thư của bạn

Bản tóm tắt ngắn những issue GitHub phù hợp với người mới.