zeroize_derive: Require zeroize(drop) or zeroize(no_drop) #212
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
The previous version of
zeroize
(v0.8) automatically derived aDrop
impl unlesszeroize(no_drop)
was passed explicitly.This felt like the right thing to do at first, however it turns out there are a lot of cases in practice where it's undesirable to derive
Drop
by default, e.g. on anyCopy
type. This was encounteredin-practice retrofitting
zeroize
into thecurve25519-dalek
crate.This changes the custom derive impl to require an explicit decision in the form of an attribute as to whether a
Drop
impl should be derived or not.Going forward (i.e. in
zeroize
1.0) derivingDrop
will need to be explicitly declared aszeroize(drop)
, and the need to explicitly specifyzeroize(no_drop)
can be removed, meaning noDrop
impl will be derived by default. However, since previous users ofzeroize
v0.8 will be expectingDrop
by default, this change makes it an explicit decision, so as to avoid people expecting to get aDrop
impl by default not actually receiving one.Once crates.io stats show
zeroize
v0.8 is no longer in use (or inzeroize
1.0, whichever comes first), the need to specify explicitly that noDrop
handler should be derived viazeroize(no_drop)
can be removed, however until then this change does the safely-explicit-but-annoying thing by default so as to correct for previous API mistakes.