From e83c134f4a391112aa5e543833a69a3e5f664b09 Mon Sep 17 00:00:00 2001 From: Taiki Endo Date: Mon, 4 Jan 2021 19:53:21 +0900 Subject: [PATCH] Replace sanitize feature with cfg(crossbeam_sanitize) Feature flag can be accidentally enabled by --all-features, so use cfg instead. --- ci/test.sh | 5 ++++- crossbeam-epoch/Cargo.toml | 3 --- crossbeam-epoch/src/internal.rs | 10 +++++----- 3 files changed, 9 insertions(+), 9 deletions(-) diff --git a/ci/test.sh b/ci/test.sh index 3994d05f0..6a9ac6c0b 100755 --- a/ci/test.sh +++ b/ci/test.sh @@ -36,8 +36,11 @@ if [[ "$RUST_VERSION" == "nightly"* ]]; then cd crossbeam-epoch cargo clean + # TODO: Once `cfg(sanitize = "..")` is stable, replace + # `cfg(crossbeam_sanitize)` with `cfg(sanitize = "..")` and remove + # `--cfg crossbeam_sanitize`. ASAN_OPTIONS="detect_odr_violation=0 detect_leaks=0" \ - RUSTFLAGS="-Z sanitizer=address" \ + RUSTFLAGS="-Z sanitizer=address --cfg crossbeam_sanitize" \ cargo run \ --release \ --target x86_64-unknown-linux-gnu \ diff --git a/crossbeam-epoch/Cargo.toml b/crossbeam-epoch/Cargo.toml index a0091612f..e24ac8738 100644 --- a/crossbeam-epoch/Cargo.toml +++ b/crossbeam-epoch/Cargo.toml @@ -33,9 +33,6 @@ alloc = [] # of crossbeam may make breaking changes to them at any time. nightly = ["crossbeam-utils/nightly", "const_fn"] -# TODO: docs -sanitize = [] # Makes it more likely to trigger any potential data races. - [dependencies] cfg-if = "1" const_fn = { version = "0.4.4", optional = true } diff --git a/crossbeam-epoch/src/internal.rs b/crossbeam-epoch/src/internal.rs index 6ad5b2236..4da5d0268 100644 --- a/crossbeam-epoch/src/internal.rs +++ b/crossbeam-epoch/src/internal.rs @@ -55,9 +55,9 @@ use crate::sync::list::{Entry, IsElement, IterError, List}; use crate::sync::queue::Queue; /// Maximum number of objects a bag can contain. -#[cfg(not(feature = "sanitize"))] +#[cfg(not(crossbeam_sanitize))] const MAX_OBJECTS: usize = 62; -#[cfg(feature = "sanitize")] +#[cfg(crossbeam_sanitize)] const MAX_OBJECTS: usize = 4; /// A bag of deferred functions. @@ -109,7 +109,7 @@ impl Default for Bag { #[rustfmt::skip] fn default() -> Self { // TODO: [no_op; MAX_OBJECTS] syntax blocked by https://github.com/rust-lang/rust/issues/49147 - #[cfg(not(feature = "sanitize"))] + #[cfg(not(crossbeam_sanitize))] return Bag { len: 0, deferreds: [ @@ -177,7 +177,7 @@ impl Default for Bag { Deferred::new(no_op_func), ], }; - #[cfg(feature = "sanitize")] + #[cfg(crossbeam_sanitize)] return Bag { len: 0, deferreds: [ @@ -278,7 +278,7 @@ impl Global { pub(crate) fn collect(&self, guard: &Guard) { let global_epoch = self.try_advance(guard); - let steps = if cfg!(feature = "sanitize") { + let steps = if cfg!(crossbeam_sanitize) { usize::max_value() } else { Self::COLLECT_STEPS