Skip to content

zeroize: breaking change for bounds #878

@ETKNeil

Description

@ETKNeil

Consider the following code

use zeroize::{Zeroize, ZeroizeOnDrop};

#[derive(zeroize::ZeroizeOnDrop, zeroize::Zeroize)]
pub struct Test<A: Marker> {
    #[zeroize(skip)]
    field: Option<A>,
}

pub trait Secret: ZeroizeOnDrop + Zeroize{}

impl<A:Marker> Secret for Test<A>{

}

pub trait Marker {}

This code used to compile with:

[dependencies]
zeroize = { version = "1", features = ["derive"] }
zeroize_derive = { version = "=1.3.3" }

But now by updating the derive

[dependencies]
zeroize = { version = "1", features = ["derive"] }
zeroize_derive = { version = "=1.4.0" }

I get

error[E0277]: the trait bound `Test<A>: Zeroize` is not satisfied
  --> src/lib.rs:11:16
   |
11 | impl<A:Marker> Secret for Test<A>{
   |                ^^^^^^ the trait `Zeroize` is not implemented for `Test<A>`
   |
note: required by a bound in `Secret`
  --> src/lib.rs:9:35
   |
9  | pub trait Secret: ZeroizeOnDrop + Zeroize{}
   |                                   ^^^^^^^ required by this bound in `Secret`
help: consider introducing a `where` clause, but there might be an alternative better way to express this requirement
   |
11 | impl<A:Marker> Secret for Test<A> where Test<A>: Zeroize{
   |                                   ++++++++++++++++++++++

For more information about this error, try `rustc --explain E0277`.
error: could not compile `test_zeroize` due to previous error

Which is due to #858

I bisected and downgrading derive to 81536ee works perfectly with my example, upgrading to syn v2 broke something

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions