Use cargo-semver-checks to make sure derive
feature doesn't change API surface
#422
Labels
experience-medium
This issue is of medium difficulty, and requires some experience
help wanted
Extra attention is needed
Zerocopy comprises two crates: zerocopy and zerocopy-derive. Zerocopy has a disabled-by-default feature called
derive
. When it's enabled, zerocopy depends on zerocopy-derive and re-exports its derives so that users can just depend on zerocopy and don't have to also depend directly on zerocopy-derive.Some of zerocopy's types implement the same traits that we provide derives for (currently,
FromZeroes
,FromBytes
,AsBytes
, andUnaligned
). When thederive
feature is enabled, we use the derives to derive implementations of those traits for our own types. When thederive
feature is disabled, we implement those traits manually.This creates a potential footgun: How do we know that the impls we emit when
derive
is enabled are identical to the impls that we emit whenderive
is disabled? Do they have the same bounds?This issue tracks using the cargo-semver-checks crate to detect such mismatches for us. We already use cargo-semver-checks in CI:
zerocopy/.github/workflows/ci.yml
Lines 207 to 227 in 3bb9a54
Specifically, this issue tracks using cargo-semver-checks to make sure that:
derive
feature is semver backwards-compatible with the absence of thederive
featurederive
feature is semver backwards-compatible with thederive
featureCombined, these two conditions should have the effect of ensuring that the APIs with and without
derive
are equivalent.This issue tracks the following concrete tasks:
ci.yml
's cargo-semver-checks use to check that:derive
feature is semver backwards-compatible with the crate without thederive
featurederive
feature is semver backwards-compatible with the crate with thederive
feature. Note that this case is extra tricky! Thederive
feature re-exports the derives, which means that the APIs are expected to differ! Specifically, we expect that the crate withoutderive
will fail to be backwards-compatible because it has "removed" these exports compared to the crate withderive
. You will need to do one of the following:ci.yml
explaining why we don't currently support this checkderive
semver-incompatible with no-derive
derive
semver-incompatible withderive
The text was updated successfully, but these errors were encountered: