Skip to content

Commit 40494d6

Browse files
committed
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. gherrit-pr-id: Gejcq7kjlhyldvg6gkkxeudox66wbfmi3
1 parent a3ad195 commit 40494d6

7 files changed

Lines changed: 16 additions & 15 deletions

File tree

.github/workflows/ci.yml

Lines changed: 5 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -523,10 +523,14 @@ jobs:
523523
THREADS=$(echo "$(nproc) * 2" | bc)
524524
echo "Running Miri tests with $THREADS threads" | tee -a $GITHUB_STEP_SUMMARY
525525
526+
# The internal miri tests use unstable rust features, so we want to make sure zerocopy
527+
# still compiles without those features for downstream users.
528+
RUSTFLAGS="--cfg miri" ./cargo.sh +$TOOLCHAIN
529+
526530
# Run under both the stacked borrows model (default) and under the tree
527531
# borrows model to ensure we're compliant with both.
528532
for EXTRA_FLAGS in "" "-Zmiri-tree-borrows"; do
529-
MIRIFLAGS="$MIRIFLAGS $EXTRA_FLAGS" ./cargo.sh +$TOOLCHAIN \
533+
MIRIFLAGS="$MIRIFLAGS $EXTRA_FLAGS --cfg __ZEROCOPY_INTERNAL_USE_ONLY_NIGHTLY_FEATURES_IN_TESTS" ./cargo.sh +$TOOLCHAIN \
530534
miri nextest run \
531535
--test-threads "$THREADS" \
532536
--package $CRATE \

Cargo.lock

Lines changed: 2 additions & 2 deletions
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

Cargo.toml

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -15,7 +15,7 @@
1515
[package]
1616
edition = "2021"
1717
name = "zerocopy"
18-
version = "0.8.48"
18+
version = "0.8.49"
1919
authors = [
2020
"Joshua Liebow-Feeser <joshlf@google.com>",
2121
"Jack Wrenn <jswrenn@amazon.com>",
@@ -124,13 +124,13 @@ __internal_use_only_features_that_work_on_stable = [
124124
]
125125

126126
[dependencies]
127-
zerocopy-derive = { version = "=0.8.48", path = "zerocopy-derive", optional = true }
127+
zerocopy-derive = { version = "=0.8.49", path = "zerocopy-derive", optional = true }
128128

129129
# The "associated proc macro pattern" ensures that the versions of zerocopy and
130130
# zerocopy-derive remain equal, even if the 'derive' feature isn't used.
131131
# See: https://github.com/matklad/macro-dep-test
132132
[target.'cfg(any())'.dependencies]
133-
zerocopy-derive = { version = "=0.8.48", path = "zerocopy-derive" }
133+
zerocopy-derive = { version = "=0.8.49", path = "zerocopy-derive" }
134134

135135
[dev-dependencies]
136136
# FIXME(#381) Remove this dependency once we have our own layout gadgets.
@@ -142,4 +142,4 @@ rustversion = "1.0"
142142
static_assertions = "1.1"
143143
testutil = { path = "testutil" }
144144
# In tests, unlike in production, zerocopy-derive is not optional
145-
zerocopy-derive = { version = "=0.8.48", path = "zerocopy-derive" }
145+
zerocopy-derive = { version = "=0.8.49", path = "zerocopy-derive" }

src/lib.rs

Lines changed: 1 addition & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -324,10 +324,7 @@
324324
#![cfg_attr(feature = "float-nightly", feature(f16, f128))]
325325
#![cfg_attr(doc_cfg, feature(doc_cfg))]
326326
#![cfg_attr(__ZEROCOPY_INTERNAL_USE_ONLY_NIGHTLY_FEATURES_IN_TESTS, feature(coverage_attribute))]
327-
#![cfg_attr(
328-
any(__ZEROCOPY_INTERNAL_USE_ONLY_NIGHTLY_FEATURES_IN_TESTS, miri),
329-
feature(layout_for_ptr)
330-
)]
327+
#![cfg_attr(__ZEROCOPY_INTERNAL_USE_ONLY_NIGHTLY_FEATURES_IN_TESTS, feature(layout_for_ptr))]
331328
#![cfg_attr(all(test, __ZEROCOPY_INTERNAL_USE_ONLY_NIGHTLY_FEATURES_IN_TESTS), feature(test))]
332329

333330
// This is a hack to allow zerocopy-derive derives to work in this crate. They

src/pointer/ptr.rs

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -233,7 +233,7 @@ mod _conversions {
233233
let raw = self.as_inner().as_non_null();
234234
// SAFETY: `self` satisfies the `Aligned` invariant, so we know that
235235
// `raw` is validly-aligned for `T`.
236-
#[cfg(miri)]
236+
#[cfg(all(__ZEROCOPY_INTERNAL_USE_ONLY_NIGHTLY_FEATURES_IN_TESTS, miri))]
237237
unsafe {
238238
crate::util::miri_promise_symbolic_alignment(
239239
raw.as_ptr().cast(),
@@ -381,7 +381,7 @@ mod _conversions {
381381
let mut raw = self.as_inner().as_non_null();
382382
// SAFETY: `self` satisfies the `Aligned` invariant, so we know that
383383
// `raw` is validly-aligned for `T`.
384-
#[cfg(miri)]
384+
#[cfg(all(__ZEROCOPY_INTERNAL_USE_ONLY_NIGHTLY_FEATURES_IN_TESTS, miri))]
385385
unsafe {
386386
crate::util::miri_promise_symbolic_alignment(
387387
raw.as_ptr().cast(),

src/util/mod.rs

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -56,7 +56,7 @@ impl<T: ?Sized> Clone for SendSyncPhantomData<T> {
5656
}
5757
}
5858

59-
#[cfg(miri)]
59+
#[cfg(all(__ZEROCOPY_INTERNAL_USE_ONLY_NIGHTLY_FEATURES_IN_TESTS, miri))]
6060
extern "Rust" {
6161
/// Miri-provided intrinsic that marks the pointer `ptr` as aligned to
6262
/// `align`.

zerocopy-derive/Cargo.toml

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -9,7 +9,7 @@
99
[package]
1010
edition = "2021"
1111
name = "zerocopy-derive"
12-
version = "0.8.48"
12+
version = "0.8.49"
1313
authors = ["Joshua Liebow-Feeser <joshlf@google.com>", "Jack Wrenn <jswrenn@amazon.com>"]
1414
description = "Custom derive for traits from the zerocopy crate"
1515
license = "BSD-2-Clause OR Apache-2.0 OR MIT"

0 commit comments

Comments
 (0)