From 7b6585c517fc22b0a978c3f0add9fcadfda89db1 Mon Sep 17 00:00:00 2001 From: Erick Tryzelaar Date: Wed, 13 May 2026 21:21:53 +0000 Subject: [PATCH] Only use `layout_for_ptr` feature for zerocopy tests This puts the use of the unstable feature `layout_for_ptr` behind `all(__ZEROCOPY_INTERNAL_USE_ONLY_NIGHTLY_FEATURES_IN_TESTS, miri)`, since it is only necessary for zerocopy tests, not for downstream users. Release 0.8.49. --- .github/workflows/ci.yml | 15 +++++++++------ Cargo.lock | 4 ++-- Cargo.toml | 8 ++++---- src/lib.rs | 5 +---- src/pointer/ptr.rs | 4 ++-- src/util/mod.rs | 2 +- zerocopy-derive/Cargo.toml | 2 +- 7 files changed, 20 insertions(+), 20 deletions(-) diff --git a/.github/workflows/ci.yml b/.github/workflows/ci.yml index f502cd0e41..54a96fbafc 100644 --- a/.github/workflows/ci.yml +++ b/.github/workflows/ci.yml @@ -526,12 +526,15 @@ jobs: # Run under both the stacked borrows model (default) and under the tree # borrows model to ensure we're compliant with both. for EXTRA_FLAGS in "" "-Zmiri-tree-borrows"; do - MIRIFLAGS="$MIRIFLAGS $EXTRA_FLAGS" ./cargo.sh +$TOOLCHAIN \ - miri nextest run \ - --test-threads "$THREADS" \ - --package $CRATE \ - --target $TARGET \ - $FEATURES + # Run with and without unstable rust features. + for EXTRA_CFG_FLAGS in "" "--cfg __ZEROCOPY_INTERNAL_USE_ONLY_NIGHTLY_FEATURES_IN_TESTS"; do + MIRIFLAGS="$MIRIFLAGS $EXTRA_FLAGS $EXTRA_CFG_FLAGS" ./cargo.sh +$TOOLCHAIN \ + miri nextest run \ + --test-threads "$THREADS" \ + --package $CRATE \ + --target $TARGET \ + $FEATURES + done done mv .cargo/config.toml.bak .cargo/config.toml diff --git a/Cargo.lock b/Cargo.lock index 8b2dad5b3e..3042ef0186 100644 --- a/Cargo.lock +++ b/Cargo.lock @@ -412,7 +412,7 @@ checksum = "589f6da84c646204747d1270a2a5661ea66ed1cced2631d546fdfb155959f9ec" [[package]] name = "zerocopy" -version = "0.8.48" +version = "0.8.49" dependencies = [ "elain", "itertools", @@ -426,7 +426,7 @@ dependencies = [ [[package]] name = "zerocopy-derive" -version = "0.8.48" +version = "0.8.49" dependencies = [ "dissimilar", "prettyplease", diff --git a/Cargo.toml b/Cargo.toml index 90904f93c7..912eaf2635 100644 --- a/Cargo.toml +++ b/Cargo.toml @@ -15,7 +15,7 @@ [package] edition = "2021" name = "zerocopy" -version = "0.8.48" +version = "0.8.49" authors = [ "Joshua Liebow-Feeser ", "Jack Wrenn ", @@ -124,13 +124,13 @@ __internal_use_only_features_that_work_on_stable = [ ] [dependencies] -zerocopy-derive = { version = "=0.8.48", path = "zerocopy-derive", optional = true } +zerocopy-derive = { version = "=0.8.49", path = "zerocopy-derive", optional = true } # The "associated proc macro pattern" ensures that the versions of zerocopy and # zerocopy-derive remain equal, even if the 'derive' feature isn't used. # See: https://github.com/matklad/macro-dep-test [target.'cfg(any())'.dependencies] -zerocopy-derive = { version = "=0.8.48", path = "zerocopy-derive" } +zerocopy-derive = { version = "=0.8.49", path = "zerocopy-derive" } [dev-dependencies] # FIXME(#381) Remove this dependency once we have our own layout gadgets. @@ -142,4 +142,4 @@ rustversion = "1.0" static_assertions = "1.1" testutil = { path = "testutil" } # In tests, unlike in production, zerocopy-derive is not optional -zerocopy-derive = { version = "=0.8.48", path = "zerocopy-derive" } +zerocopy-derive = { version = "=0.8.49", path = "zerocopy-derive" } diff --git a/src/lib.rs b/src/lib.rs index 0c66144932..07d1bce9e7 100644 --- a/src/lib.rs +++ b/src/lib.rs @@ -324,10 +324,7 @@ #![cfg_attr(feature = "float-nightly", feature(f16, f128))] #![cfg_attr(doc_cfg, feature(doc_cfg))] #![cfg_attr(__ZEROCOPY_INTERNAL_USE_ONLY_NIGHTLY_FEATURES_IN_TESTS, feature(coverage_attribute))] -#![cfg_attr( - any(__ZEROCOPY_INTERNAL_USE_ONLY_NIGHTLY_FEATURES_IN_TESTS, miri), - feature(layout_for_ptr) -)] +#![cfg_attr(__ZEROCOPY_INTERNAL_USE_ONLY_NIGHTLY_FEATURES_IN_TESTS, feature(layout_for_ptr))] #![cfg_attr(all(test, __ZEROCOPY_INTERNAL_USE_ONLY_NIGHTLY_FEATURES_IN_TESTS), feature(test))] // This is a hack to allow zerocopy-derive derives to work in this crate. They diff --git a/src/pointer/ptr.rs b/src/pointer/ptr.rs index 30e7a7080f..5071faa1f8 100644 --- a/src/pointer/ptr.rs +++ b/src/pointer/ptr.rs @@ -233,7 +233,7 @@ mod _conversions { let raw = self.as_inner().as_non_null(); // SAFETY: `self` satisfies the `Aligned` invariant, so we know that // `raw` is validly-aligned for `T`. - #[cfg(miri)] + #[cfg(all(__ZEROCOPY_INTERNAL_USE_ONLY_NIGHTLY_FEATURES_IN_TESTS, miri))] unsafe { crate::util::miri_promise_symbolic_alignment( raw.as_ptr().cast(), @@ -381,7 +381,7 @@ mod _conversions { let mut raw = self.as_inner().as_non_null(); // SAFETY: `self` satisfies the `Aligned` invariant, so we know that // `raw` is validly-aligned for `T`. - #[cfg(miri)] + #[cfg(all(__ZEROCOPY_INTERNAL_USE_ONLY_NIGHTLY_FEATURES_IN_TESTS, miri))] unsafe { crate::util::miri_promise_symbolic_alignment( raw.as_ptr().cast(), diff --git a/src/util/mod.rs b/src/util/mod.rs index 4016f8f048..de23f88d97 100644 --- a/src/util/mod.rs +++ b/src/util/mod.rs @@ -56,7 +56,7 @@ impl Clone for SendSyncPhantomData { } } -#[cfg(miri)] +#[cfg(all(__ZEROCOPY_INTERNAL_USE_ONLY_NIGHTLY_FEATURES_IN_TESTS, miri))] extern "Rust" { /// Miri-provided intrinsic that marks the pointer `ptr` as aligned to /// `align`. diff --git a/zerocopy-derive/Cargo.toml b/zerocopy-derive/Cargo.toml index dd7373012d..343edf87bb 100644 --- a/zerocopy-derive/Cargo.toml +++ b/zerocopy-derive/Cargo.toml @@ -9,7 +9,7 @@ [package] edition = "2021" name = "zerocopy-derive" -version = "0.8.48" +version = "0.8.49" authors = ["Joshua Liebow-Feeser ", "Jack Wrenn "] description = "Custom derive for traits from the zerocopy crate" license = "BSD-2-Clause OR Apache-2.0 OR MIT"