Skip to content

Commit

Permalink
Replace sanitize feature with cfg(crossbeam_sanitize)
Browse files Browse the repository at this point in the history
Feature flag can be accidentally enabled by --all-features, so use cfg
instead.
  • Loading branch information
taiki-e committed Jan 4, 2021
1 parent 8796beb commit e83c134
Show file tree
Hide file tree
Showing 3 changed files with 9 additions and 9 deletions.
5 changes: 4 additions & 1 deletion ci/test.sh
Original file line number Diff line number Diff line change
Expand Up @@ -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 \
Expand Down
3 changes: 0 additions & 3 deletions crossbeam-epoch/Cargo.toml
Original file line number Diff line number Diff line change
Expand Up @@ -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 }
Expand Down
10 changes: 5 additions & 5 deletions crossbeam-epoch/src/internal.rs
Original file line number Diff line number Diff line change
Expand Up @@ -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.
Expand Down Expand Up @@ -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: [
Expand Down Expand Up @@ -177,7 +177,7 @@ impl Default for Bag {
Deferred::new(no_op_func),
],
};
#[cfg(feature = "sanitize")]
#[cfg(crossbeam_sanitize)]
return Bag {
len: 0,
deferreds: [
Expand Down Expand Up @@ -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
Expand Down

0 comments on commit e83c134

Please sign in to comment.