From f590be17467609aa773c9163b0f27c0f046a1600 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(test, miri)`, since it is only necessary for zerocopy tests, not for downstream users. Release 0.8.49. gherrit-pr-id: Gouy5nmgied3joawzp6mdecm3nuhi35jh --- Cargo.lock | 4 ++-- Cargo.toml | 8 ++++---- src/lib.rs | 2 +- src/pointer/ptr.rs | 4 ++-- zerocopy-derive/Cargo.toml | 2 +- 5 files changed, 10 insertions(+), 10 deletions(-) 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..3d666cf5df 100644 --- a/src/lib.rs +++ b/src/lib.rs @@ -325,7 +325,7 @@ #![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), + any(__ZEROCOPY_INTERNAL_USE_ONLY_NIGHTLY_FEATURES_IN_TESTS, all(test, miri)), feature(layout_for_ptr) )] #![cfg_attr(all(test, __ZEROCOPY_INTERNAL_USE_ONLY_NIGHTLY_FEATURES_IN_TESTS), feature(test))] diff --git a/src/pointer/ptr.rs b/src/pointer/ptr.rs index 30e7a7080f..4ac7b8312f 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(test, 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(test, miri))] unsafe { crate::util::miri_promise_symbolic_alignment( raw.as_ptr().cast(), 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"