Skip to content
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

Closed
wants to merge 1 commit into from
Closed

Lower MSRV to 1.56 #574

wants to merge 1 commit into from

Conversation

joshlf
Copy link
Member

@joshlf joshlf commented Oct 31, 2023

In order to do this, we make a few changes:

  • In 1.56, panicking is not supported in const fns. In order to
    support 1.56 while still panicking in const fns 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 fns, we put debug assertions behind
      #[cfg(zerocopy_panic_in_const_fn)].
    • In some const fns, 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

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
Comment on lines 40 to 41
.ok_or("failed to find msrv: no `rust-version` key present")?
.to_string();
Copy link
Member Author

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.

@joshlf joshlf changed the title Lower MSRV to 1.57 Lower MSRV to 1.56 Nov 2, 2023
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"
Copy link
Member Author

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.

joshlf added a commit that referenced this pull request Dec 28, 2023
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
joshlf added a commit that referenced this pull request Dec 28, 2023
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
joshlf added a commit that referenced this pull request Dec 28, 2023
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
joshlf added a commit that referenced this pull request Jan 18, 2024
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
github-merge-queue bot pushed a commit that referenced this pull request Jan 18, 2024
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
@joshlf
Copy link
Member Author

joshlf commented Feb 12, 2024

Superseded by #855.

@joshlf joshlf closed this Feb 12, 2024
@joshlf joshlf deleted the lower-msrv branch February 12, 2024 20:45
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

1 participant