Skip to content

Commit 16babf9

Browse files
committed
Relax zerocopy-derive's MSRV policy
Makes progress on #1085
1 parent 7f3f2c0 commit 16babf9

File tree

3 files changed

+29
-49
lines changed

3 files changed

+29
-49
lines changed

.github/workflows/ci.yml

Lines changed: 14 additions & 44 deletions
Original file line numberDiff line numberDiff line change
@@ -79,6 +79,16 @@ jobs:
7979
~/.cargo/
8080
key: ${{ runner.os }}-cargo-${{ hashFiles('**/Cargo.toml') }}
8181

82+
# Ensure that Cargo resolves the minimum possible syn version so that if we
83+
# accidentally make a change which depends upon features added in more
84+
# recent versions of syn, we'll catch it in CI.
85+
- name: Pin syn dependency
86+
run: |
87+
set -eo pipefail
88+
# Override the exising `syn` dependency with one which requires an exact
89+
# version.
90+
cargo add -p zerocopy-derive 'syn@=2.0.31'
91+
8292
- name: Configure environment variables
8393
run: |
8494
set -eo pipefail
@@ -318,49 +328,6 @@ jobs:
318328
diff <(./generate-readme.sh) README.md
319329
exit $?
320330
321-
check_msrv:
322-
needs: generate_cache
323-
runs-on: ubuntu-latest
324-
name: Check MSRVs match
325-
steps:
326-
- uses: actions/checkout@b4ffde65f46336ab88eb53be808477a3936bae11 # v4.1.1
327-
328-
- uses: actions/cache@704facf57e6136b1bc63b828d79edcd491f0ee84 # v3.3.2
329-
with:
330-
path: |
331-
~/.cargo/
332-
key: ${{ runner.os }}-cargo-${{ hashFiles('**/Cargo.toml') }}
333-
334-
# Make sure that the MSRV in zerocopy's and zerocopy-derive's `Cargo.toml`
335-
# files are the same. In CI, we test with a single MSRV (the one indicated
336-
# in zerocopy's `Cargo.toml`), so it's important that:
337-
# - zerocopy-derive's MSRV is not lower than zerocopy's (we don't test with
338-
# a lower MSRV in CI, so we couldn't guarantee that zerocopy-derive
339-
# actually built and ran on a lower MSRV)
340-
# - zerocopy-derive's MSRV is not higher than zerocopy's (this would mean
341-
# that compiling zerocopy with the `derive` feature enabled would fail
342-
# on its own published MSRV)
343-
- name: Check MSRVs match
344-
run: |
345-
set -eo pipefail
346-
347-
# Usage: msrv <crate-name>
348-
function msrv {
349-
cargo metadata --format-version 1 | jq -r ".packages[] | select(.name == \"$1\").rust_version"
350-
}
351-
352-
ver_zerocopy=$(msrv zerocopy)
353-
ver_zerocopy_derive=$(msrv zerocopy-derive)
354-
355-
if [[ "$ver_zerocopy" == "$ver_zerocopy_derive" ]]; then
356-
echo "Same MSRV ($ver_zerocopy) found for zerocopy and zerocopy-derive." | tee -a $GITHUB_STEP_SUMMARY
357-
exit 0
358-
else
359-
echo "Different MSRVs found for zerocopy ($ver_zerocopy) and zerocopy-derive ($ver_zerocopy_derive)." \
360-
| tee -a $GITHUB_STEP_SUMMARY >&2
361-
exit 1
362-
fi
363-
364331
check_versions:
365332
needs: generate_cache
366333
runs-on: ubuntu-latest
@@ -454,6 +421,9 @@ jobs:
454421

455422
- name: Populate cache
456423
run: |
424+
# See comment on "Pin syn dependency" job for why we do this.
425+
cargo add -p zerocopy-derive 'syn@=2.0.31'
426+
457427
# Ensure all dependencies are downloaded - both for our crates and for
458428
# tools we use in CI. We don't care about these tools succeeding for
459429
# two reasons: First, this entire job is best-effort since it's just a
@@ -484,7 +454,7 @@ jobs:
484454
# 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
485455
if: failure()
486456
runs-on: ubuntu-latest
487-
needs: [build_test, kani, check_fmt, check_readme, check_msrv, check_versions, generate_cache]
457+
needs: [build_test, kani, check_fmt, check_readme, check_versions, generate_cache]
488458
steps:
489459
- name: Mark the job as failed
490460
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

zerocopy-derive/Cargo.toml

Lines changed: 0 additions & 1 deletion
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.60.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,

0 commit comments

Comments
 (0)