-
Notifications
You must be signed in to change notification settings - Fork 107
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Lower MSRV to 1.56 #574
Lower MSRV to 1.56 #574
Conversation
In order to do this, we make a few changes: - In 1.56, panicking is not supported in `const fn`s. In order to support 1.56 while still panicking in `const fn`s in later versions, we make a few changes: - We introduce a `build.rs` script which detects the Rust toolchain version and emits the cfg `zerocopy_panic_in_const_fn` if the Rust version is at least 1.57. - In some `const fn`s, we put debug assertions behind `#[cfg(zerocopy_panic_in_const_fn)]`. - In some `const fn`s, we replace `unreachable!()` with non-panicking code when `#[cfg(not(zerocopy_panic_in_const_fn))]`. - In one case, we compile a method as either a `const fn` or a non-`const fn` depending on `zerocopy_panic_in_const_fn`. - We replace `&*dst` with `transmute(dst)`. - We make sure that, in `impl` blocks, `const` parameters always come last. - We make the `byteorder` feature/crate dependency off by default. This is a breaking change, and so we bump the version number to 0.8.0-alpha. Release 0.8.0-alpha. Makes progress on #554
.ok_or("failed to find msrv: no `rust-version` key present")? | ||
.to_string(); |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
We'll need to find a way to work around oli-obk/cargo_metadata#253.
authors = ["Joshua Liebow-Feeser <[email protected]>"] | ||
description = "Utilities for zero-copy parsing and serialization" | ||
license = "BSD-2-Clause OR Apache-2.0 OR MIT" | ||
repository = "https://github.com/google/zerocopy" | ||
rust-version = "1.60.0" | ||
rust-version = "1.56.0" |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
We may need to update our testing infrastructure to support testing on more stable toolchains other than one MSRV and one stable. In particular, we'll want to test on every toolchain that enables some functionality in build.rs
. If our MSRV is A, our build.rs
emits a particular cfg for versions B and above (B > A), and our pinned stable is C (C > B), then if we only test on A and C in CI, it's possible for behavior which is gated behind the cfg to be broken on any version in the range [B, C). Thus, we should test on B as well. In the general case, we need the ability to test on the full list of toolchain versions that invoke distinct build.rs
behavior.
Remove the `byteorder` feature and the dependency on the `byteorder` crate. Replace the `ByteOrder` trait and types which implement it from the `byteorder` crate with our own native implementations. This prepares us for a future commit in which we will make some of our functions and methods `const`. This commit doesn't implement this yet because it doesn't play nicely with our current MSRV; in order to support this, we'll need to introduce machinery that allows us to compile functions as conditionally `const` depending on what Rust toolchain version is used. See #574 for a prototype of this machinery. Add `Usize` and `Isize` byte order-aware types. Closes #438
Remove the `byteorder` feature and the dependency on the `byteorder` crate. Replace the `ByteOrder` trait and types which implement it from the `byteorder` crate with our own native implementations. This prepares us for a future commit in which we will make some of our functions and methods `const`. This commit doesn't implement this yet because it doesn't play nicely with our current MSRV; in order to support this, we'll need to introduce machinery that allows us to compile functions as conditionally `const` depending on what Rust toolchain version is used. See #574 for a prototype of this machinery. Add `Usize` and `Isize` byte order-aware types. Closes #438
Remove the `byteorder` feature and the dependency on the `byteorder` crate. Replace the `ByteOrder` trait and types which implement it from the `byteorder` crate with our own native implementations. This prepares us for a future commit in which we will make some of our functions and methods `const`. This commit doesn't implement this yet because it doesn't play nicely with our current MSRV; in order to support this, we'll need to introduce machinery that allows us to compile functions as conditionally `const` depending on what Rust toolchain version is used. See #574 for a prototype of this machinery. Add `Usize` and `Isize` byte order-aware types. Closes #438
Remove the `byteorder` feature and the dependency on the `byteorder` crate. Replace the `ByteOrder` trait and types which implement it from the `byteorder` crate with our own native implementations. This prepares us for a future commit in which we will make some of our functions and methods `const`. This commit doesn't implement this yet because it doesn't play nicely with our current MSRV; in order to support this, we'll need to introduce machinery that allows us to compile functions as conditionally `const` depending on what Rust toolchain version is used. See #574 for a prototype of this machinery. Add `Usize` and `Isize` byte order-aware types. Closes #438
Remove the `byteorder` feature and the dependency on the `byteorder` crate. Replace the `ByteOrder` trait and types which implement it from the `byteorder` crate with our own native implementations. This prepares us for a future commit in which we will make some of our functions and methods `const`. This commit doesn't implement this yet because it doesn't play nicely with our current MSRV; in order to support this, we'll need to introduce machinery that allows us to compile functions as conditionally `const` depending on what Rust toolchain version is used. See #574 for a prototype of this machinery. Add `Usize` and `Isize` byte order-aware types. Closes #438
Superseded by #855. |
In order to do this, we make a few changes:
const fn
s. In order tosupport 1.56 while still panicking in
const fn
s in later versions,we make a few changes:
build.rs
script which detects the Rust toolchainversion and emits the cfg
zerocopy_panic_in_const_fn
if the Rustversion is at least 1.57.
const fn
s, we put debug assertions behind#[cfg(zerocopy_panic_in_const_fn)]
.const fn
s, we replaceunreachable!()
with non-panickingcode when
#[cfg(not(zerocopy_panic_in_const_fn))]
.const fn
or anon-
const fn
depending onzerocopy_panic_in_const_fn
.&*dst
withtransmute(dst)
.impl
blocks,const
parameters always comelast.
byteorder
feature/crate dependency off by default. Thisis a breaking change, and so we bump the version number to
0.8.0-alpha.
Release 0.8.0-alpha.
Makes progress on #554