Write 0.8 upgrading guide (and maybe write a cargo fix
-like tool)
#1295
Labels
blocking-next-release
This issue should be resolved before we release on crates.io
Progress
Details
As described in #1288 (comment), and in my own personal experience upgrading the version of zerocopy vendored in Fuchsia, upgrading from 0.7 to 0.8 creates a large amount of churn. This falls into a few primary buckets:
Immutable
and/orKnownLayout
#[derive(FromZeroes, FromBytes)]
now breaks, and needs to be replaced with just#[derive(FromBytes)]
FromZeroes
andAsBytes
have been renamed toFromZeros
andIntoBytes
, respectivelyOption
toResult
B: ByteSlice
now requireB: SplitByteSlice
Upgrading guide
We should at a minimum write a detailed upgrading guide that explains what changes will need to be made, and what compiler errors to expect.
We may also want to include a note about the
byteorder
feature being removed.Upgrade tool
We may also want to write a
cargo fix
-like tool that performs some of the upgrade automatically, as much of this can be done mechanically. In particular, the following set of transformations would result in code which is nearly semantically identical under 0.8:FromZeroes
andAsBytes
toFromZeros
andIntoBytes
FromZeros
,FromBytes
, orAsBytes
is used (especially in derives and in trait bounds), addImmutable
andKnownLayout
as wellFromZeros
andFromBytes
are derived, removeFromZeros
.ok()
to mostFromBytes
methods andRef
constructorsByteSlice
withSplitByteSlice
in trait boundsSome of these could be done with a relatively low false positive rate just using standard unix shell tools. Some of them would be better served by a more powerful tool that can parse Rust code and resolve item paths (e.g., detecting whether a use of
Ref::new
refers tozerocopy::Ref
or some otherRef
).A few suggestions from this thread:
#[derive]
syn
crate with the visitor feature to browse and edit the code, thenprettyplease
to get a readable output."rustc-driver
pluginrust-analyzer
search and replaceThe text was updated successfully, but these errors were encountered: