Skip to content

Commit 8c9f141

Browse files
committed
Relax zerocopy-derive's MSRV policy
This also bumps zerocopy-derive's syn dependency to 2.0.46. We don't actually need this for zerocopy-derive. However, in CI, we modify zerocopy-derive to take an "exact" dependency on syn (ie, '=2.0.46' instead of '2.0.46'). One of the transitive dependencies of our `testutil` crate requires syn 2.0.46 or later. We could in principle make CI smart enough to test with both syn versions, but we wouldn't gain much for that complexity - it's easier to just bump the version. Fixes #1085 See also #1481
1 parent b90e1a6 commit 8c9f141

File tree

5 files changed

+33
-62
lines changed

5 files changed

+33
-62
lines changed

.github/workflows/ci.yml

Lines changed: 17 additions & 23 deletions
Original file line numberDiff line numberDiff line change
@@ -120,6 +120,16 @@ jobs:
120120
- name: Populate cache
121121
uses: ./.github/actions/cache
122122

123+
# Ensure that Cargo resolves the minimum possible syn version so that if we
124+
# accidentally make a change which depends upon features added in more
125+
# recent versions of syn, we'll catch it in CI.
126+
- name: Pin syn dependency
127+
run: |
128+
set -eo pipefail
129+
# Override the exising `syn` dependency with one which requires an exact
130+
# version.
131+
cargo add -p zerocopy-derive 'syn@=2.0.46'
132+
123133
- name: Configure environment variables
124134
run: |
125135
set -eo pipefail
@@ -438,28 +448,6 @@ jobs:
438448
- name: Check README.md
439449
run: ./ci/check_readme.sh
440450

441-
check_msrv:
442-
needs: generate_cache
443-
runs-on: ubuntu-latest
444-
name: Check MSRVs match
445-
steps:
446-
- uses: actions/checkout@692973e3d937129bcbf40652eb9f2f61becf3332 # v4.1.7
447-
448-
- name: Populate cache
449-
uses: ./.github/actions/cache
450-
451-
# Make sure that the MSRV in zerocopy's and zerocopy-derive's `Cargo.toml`
452-
# files are the same. In CI, we test with a single MSRV (the one indicated
453-
# in zerocopy's `Cargo.toml`), so it's important that:
454-
# - zerocopy-derive's MSRV is not lower than zerocopy's (we don't test with
455-
# a lower MSRV in CI, so we couldn't guarantee that zerocopy-derive
456-
# actually built and ran on a lower MSRV)
457-
# - zerocopy-derive's MSRV is not higher than zerocopy's (this would mean
458-
# that compiling zerocopy with the `derive` feature enabled would fail
459-
# on its own published MSRV)
460-
- name: Check MSRVs match
461-
run: ./ci/check_msrv.sh
462-
463451
check_versions:
464452
needs: generate_cache
465453
runs-on: ubuntu-latest
@@ -504,6 +492,12 @@ jobs:
504492
# in parallel.
505493
#
506494
# [1] https://stackoverflow.com/a/42139535/836390
495+
496+
# See comment on "Pin syn dependency" job for why we do this. It needs
497+
# to happen before the subsequent `cargo check`, so we don't
498+
# background it.
499+
cargo add -p zerocopy-derive 'syn@=2.0.46' &> /dev/null
500+
507501
cargo check --workspace --tests &> /dev/null &
508502
cargo metadata &> /dev/null &
509503
cargo install cargo-readme --version 3.2.0 &> /dev/null &
@@ -559,7 +553,7 @@ jobs:
559553
# https://docs.github.com/en/pull-requests/collaborating-with-pull-requests/collaborating-on-repositories-with-code-quality-features/troubleshooting-required-status-checks#handling-skipped-but-required-checks
560554
if: failure()
561555
runs-on: ubuntu-latest
562-
needs: [build_test, kani, check_fmt, check_readme, check_msrv, check_versions, generate_cache, check-all-toolchains-tested, check-job-dependencies, run-git-hooks]
556+
needs: [build_test, kani, check_fmt, check_readme, check_versions, generate_cache, check-all-toolchains-tested, check-job-dependencies, run-git-hooks]
563557
steps:
564558
- name: Mark the job as failed
565559
run: exit 1

POLICIES.md

Lines changed: 15 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -89,10 +89,21 @@ documented guarantees do not hold.
8989

9090
## MSRV
9191

92-
Our minimum supported Rust version (MSRV) is encoded in our `Cargo.toml` file.
93-
We consider an increase in MSRV to be a semver-breaking change, and will only
94-
increase our MSRV during semver-breaking version changes (e.g., 0.1 -> 0.2, 1.0
95-
-> 2.0, etc).
92+
<!-- Our policy used to be simply that MSRV was a breaking change in all
93+
circumstances. This implicitly relied on syn having the same MSRV policy, which
94+
it does not. See #1085 and #1088. -->
95+
96+
Without the `derive` feature enabled, zerocopy's minimum supported Rust version
97+
(MSRV) is encoded the `package.rust-version` field in its `Cargo.toml` file. For
98+
zerocopy, we consider an increase in MSRV to be a semver-breaking change, and
99+
will only increase our MSRV during semver-breaking version changes (e.g., 0.1 ->
100+
0.2, 1.0 -> 2.0, etc).
101+
102+
For zerocopy with the `derive` feature enabled, and for the zerocopy-derive
103+
crate, we inherit the MSRV of our sole external dependency, syn. As of this
104+
writing (2024-07-02), syn does *not* consider MSRV increases to be
105+
semver-breaking changes. Thus, using the `derive` feature may result in the
106+
effective MSRV increasing within a semver version train.
96107

97108
## Yanking
98109

ci/check_msrv.sh

Lines changed: 0 additions & 28 deletions
This file was deleted.

githooks/pre-push

Lines changed: 0 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -17,7 +17,6 @@ echo "Running pre-push git hook: $0"
1717
./ci/check_fmt.sh & FMT_PID=$!
1818
./ci/check_all_toolchains_tested.sh >/dev/null & TOOLCHAINS_PID=$!
1919
./ci/check_job_dependencies.sh >/dev/null & JOB_DEPS_PID=$!
20-
./ci/check_msrv.sh >/dev/null & MSRV_PID=$!
2120
./ci/check_readme.sh >/dev/null & README_PID=$!
2221
./ci/check_versions.sh >/dev/null & VERSIONS_PID=$!
2322

@@ -30,7 +29,6 @@ echo "Running pre-push git hook: $0"
3029
wait $FMT_PID
3130
wait $TOOLCHAINS_PID
3231
wait $JOB_DEPS_PID
33-
wait $MSRV_PID
3432
wait $README_PID
3533
wait $VERSIONS_PID
3634

zerocopy-derive/Cargo.toml

Lines changed: 1 addition & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -14,7 +14,6 @@ authors = ["Joshua Liebow-Feeser <[email protected]>"]
1414
description = "Custom derive for traits from the zerocopy crate"
1515
license = "BSD-2-Clause OR Apache-2.0 OR MIT"
1616
repository = "https://github.com/google/zerocopy"
17-
rust-version = "1.56.0"
1817

1918
# We prefer to include tests when publishing to crates.io so that Crater [1] can
2019
# detect regressions in our test suite. These two tests are excessively large,
@@ -29,10 +28,7 @@ proc-macro = true
2928
[dependencies]
3029
proc-macro2 = "1.0.1"
3130
quote = "1.0.10"
32-
# This pinned dependency is a temporary work-around for #1085. Per #1088, we
33-
# will not ship 0.8 until we've removed this work-around and replaced it with a
34-
# more permanent solution.
35-
syn = "=2.0.55"
31+
syn = "2.0.46"
3632

3733
[dev-dependencies]
3834
# We don't use this directly, but trybuild does. On the MSRV toolchain, the

0 commit comments

Comments
 (0)