Skip to content

Commit 7dafc0b

Browse files
add raw_ref_op feature gate to examples & tests
Due to `raw_ref_op` not being stable until rustc 1.82 (which is the "proper" msrv, when no default features), we have to explicitly enable it using a feature gate. This commit also adds a flag `RUSTC_RAW_REF_OP_IS_STABLE` to the `build.rs` to communicate with cargo for conditional compilation as to whether the `raw_ref_op` feature gate is needed, based on the RUSTC version. Finally it adds the feature gate behind the conditional flag mentioned above to the examples and tests, so they don't fail the nightly-msrv checks (where `raw_ref_op` is currently unstable). Signed-off-by: Antonio Hickey <[email protected]>
1 parent 87facba commit 7dafc0b

File tree

4 files changed

+8
-0
lines changed

4 files changed

+8
-0
lines changed

build.rs

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -3,6 +3,7 @@ use rustc_version::{version, Version};
33
fn main() {
44
println!("cargo::rustc-check-cfg=cfg(RUSTC_LINT_REASONS_IS_STABLE)");
55
println!("cargo::rustc-check-cfg=cfg(RUSTC_NEW_UNINIT_IS_STABLE)");
6+
println!("cargo::rustc-check-cfg=cfg(RUSTC_RAW_REF_OP_IS_STABLE)");
67
println!("cargo::rustc-check-cfg=cfg(CONFIG_RUSTC_HAS_UNSAFE_PINNED)");
78
if version().unwrap() >= Version::parse("1.81.0").unwrap()
89
|| version().unwrap() >= Version::parse("1.81.0-nightly").unwrap()
@@ -12,6 +13,9 @@ fn main() {
1213
if version().unwrap() >= Version::parse("1.82.0").unwrap() {
1314
println!("cargo:rustc-cfg=RUSTC_NEW_UNINIT_IS_STABLE");
1415
}
16+
if version().unwrap() >= Version::parse("1.82.0").unwrap() {
17+
println!("cargo:rustc-cfg=RUSTC_RAW_REF_OP_IS_STABLE");
18+
}
1519
if version().unwrap() >= Version::parse("1.88.0-nightly").unwrap() {
1620
println!("cargo:rustc-cfg=CONFIG_RUSTC_HAS_UNSAFE_PINNED");
1721
}

examples/big_struct_in_place.rs

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,7 @@
11
// SPDX-License-Identifier: Apache-2.0 OR MIT
22

3+
#![cfg_attr(not(RUSTC_RAW_REF_OP_IS_STABLE), feature(raw_ref_op))]
4+
35
use pin_init::*;
46

57
// Struct with size over 1GiB

examples/pthread_mutex.rs

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -4,6 +4,7 @@
44
#![allow(clippy::undocumented_unsafe_blocks)]
55
#![cfg_attr(feature = "alloc", feature(allocator_api))]
66
#![cfg_attr(not(RUSTC_LINT_REASONS_IS_STABLE), feature(lint_reasons))]
7+
#![cfg_attr(not(RUSTC_RAW_REF_OP_IS_STABLE), feature(raw_ref_op))]
78

89
#[cfg(not(windows))]
910
mod pthread_mtx {

tests/zeroing.rs

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,5 @@
11
#![cfg_attr(not(RUSTC_LINT_REASONS_IS_STABLE), feature(lint_reasons))]
2+
#![cfg_attr(not(RUSTC_RAW_REF_OP_IS_STABLE), feature(raw_ref_op))]
23

34
use std::marker::PhantomPinned;
45

0 commit comments

Comments
 (0)