diff --git a/Cargo.toml b/Cargo.toml index 12352de6d..ea2fb5325 100644 --- a/Cargo.toml +++ b/Cargo.toml @@ -23,6 +23,7 @@ travis-ci = { repository = "crossbeam-rs/crossbeam" } default = ["std"] nightly = ["crossbeam-epoch/nightly", "crossbeam-utils/nightly", "crossbeam-queue/nightly"] std = [ + "alloc", "crossbeam-channel", "crossbeam-deque", "crossbeam-epoch/std", diff --git a/crossbeam-epoch/Cargo.toml b/crossbeam-epoch/Cargo.toml index 14a9ac50b..66107b26b 100644 --- a/crossbeam-epoch/Cargo.toml +++ b/crossbeam-epoch/Cargo.toml @@ -18,7 +18,7 @@ categories = ["concurrency", "memory-management", "no-std"] [features] default = ["std"] nightly = ["crossbeam-utils/nightly"] -std = ["crossbeam-utils/std", "lazy_static"] +std = ["alloc", "crossbeam-utils/std", "lazy_static"] alloc = ["crossbeam-utils/alloc"] sanitize = [] # Makes it more likely to trigger any potential data races. diff --git a/crossbeam-epoch/src/lib.rs b/crossbeam-epoch/src/lib.rs index 2498f9dd8..cd05c5d88 100644 --- a/crossbeam-epoch/src/lib.rs +++ b/crossbeam-epoch/src/lib.rs @@ -61,20 +61,14 @@ #[macro_use] extern crate cfg_if; +#[cfg(feature = "alloc")] +extern crate alloc; #[cfg(feature = "std")] extern crate core; -cfg_if! { - if #[cfg(feature = "alloc")] { - extern crate alloc; - } else if #[cfg(feature = "std")] { - extern crate std as alloc; - } -} - #[cfg_attr(feature = "nightly", cfg(target_has_atomic = "ptr"))] cfg_if! { - if #[cfg(any(feature = "alloc", feature = "std"))] { + if #[cfg(feature = "alloc")] { extern crate crossbeam_utils; #[macro_use] extern crate memoffset; diff --git a/crossbeam-queue/Cargo.toml b/crossbeam-queue/Cargo.toml index df62887af..5520e44ae 100644 --- a/crossbeam-queue/Cargo.toml +++ b/crossbeam-queue/Cargo.toml @@ -17,7 +17,7 @@ categories = ["concurrency", "data-structures"] [features] default = ["std"] -std = ["crossbeam-utils/std"] +std = ["alloc", "crossbeam-utils/std"] alloc = ["crossbeam-utils/alloc"] nightly = [] diff --git a/crossbeam-queue/src/lib.rs b/crossbeam-queue/src/lib.rs index 0bf12fb01..878728aa4 100644 --- a/crossbeam-queue/src/lib.rs +++ b/crossbeam-queue/src/lib.rs @@ -13,24 +13,19 @@ #![cfg_attr(not(feature = "std"), no_std)] #![cfg_attr(feature = "nightly", feature(cfg_target_has_atomic))] +#[cfg_attr(feature = "nightly", cfg(target_has_atomic = "ptr"))] #[macro_use] extern crate cfg_if; +#[cfg(feature = "alloc")] +extern crate alloc; #[cfg(feature = "std")] extern crate core; -cfg_if! { - if #[cfg(feature = "alloc")] { - extern crate alloc; - } else if #[cfg(feature = "std")] { - extern crate std as alloc; - } -} - extern crate crossbeam_utils; #[cfg_attr(feature = "nightly", cfg(target_has_atomic = "ptr"))] cfg_if! { - if #[cfg(any(feature = "alloc", feature = "std"))] { + if #[cfg(feature = "alloc")] { mod array_queue; mod err; mod seg_queue; diff --git a/crossbeam-skiplist/Cargo.toml b/crossbeam-skiplist/Cargo.toml index 74d36c676..aa335733d 100644 --- a/crossbeam-skiplist/Cargo.toml +++ b/crossbeam-skiplist/Cargo.toml @@ -18,7 +18,7 @@ categories = ["algorithms", "concurrency", "data-structures", "no-std"] [features] default = ["std"] nightly = ["crossbeam-epoch/nightly", "crossbeam-utils/nightly"] -std = ["crossbeam-epoch/std", "crossbeam-utils/std"] +std = ["alloc", "crossbeam-epoch/std", "crossbeam-utils/std"] alloc = ["crossbeam-epoch/alloc", "crossbeam-utils/alloc"] [dependencies] diff --git a/crossbeam-skiplist/src/lib.rs b/crossbeam-skiplist/src/lib.rs index 17e4a7bfb..2ab61b46c 100644 --- a/crossbeam-skiplist/src/lib.rs +++ b/crossbeam-skiplist/src/lib.rs @@ -7,20 +7,14 @@ #[macro_use] extern crate cfg_if; +#[cfg(feature = "alloc")] +extern crate alloc; #[cfg(feature = "std")] extern crate core; -cfg_if! { - if #[cfg(feature = "alloc")] { - extern crate alloc; - } else if #[cfg(feature = "std")] { - extern crate std as alloc; - } -} - #[cfg_attr(feature = "nightly", cfg(target_has_atomic = "ptr"))] cfg_if! { - if #[cfg(any(feature = "alloc", feature = "std"))] { + if #[cfg(feature = "alloc")] { extern crate crossbeam_epoch as epoch; extern crate crossbeam_utils as utils; extern crate scopeguard; diff --git a/crossbeam-utils/Cargo.toml b/crossbeam-utils/Cargo.toml index 069043a31..d46bfef9b 100644 --- a/crossbeam-utils/Cargo.toml +++ b/crossbeam-utils/Cargo.toml @@ -18,7 +18,7 @@ categories = ["algorithms", "concurrency", "data-structures", "no-std"] [features] default = ["std"] nightly = [] -std = ["lazy_static"] +std = ["alloc", "lazy_static"] alloc = [] [dependencies] diff --git a/crossbeam-utils/src/lib.rs b/crossbeam-utils/src/lib.rs index 06f23beb4..fea9f16aa 100644 --- a/crossbeam-utils/src/lib.rs +++ b/crossbeam-utils/src/lib.rs @@ -33,17 +33,11 @@ #[macro_use] extern crate cfg_if; +#[cfg(feature = "alloc")] +extern crate alloc; #[cfg(feature = "std")] extern crate core; -cfg_if! { - if #[cfg(feature = "alloc")] { - extern crate alloc; - } else if #[cfg(feature = "std")] { - extern crate std as alloc; - } -} - #[cfg_attr(feature = "nightly", cfg(target_has_atomic = "ptr"))] pub mod atomic; diff --git a/src/lib.rs b/src/lib.rs index 650b37260..2b0fc11b2 100644 --- a/src/lib.rs +++ b/src/lib.rs @@ -49,17 +49,11 @@ #[macro_use] extern crate cfg_if; +#[cfg(feature = "alloc")] +extern crate alloc; #[cfg(feature = "std")] extern crate core; -cfg_if! { - if #[cfg(feature = "alloc")] { - extern crate alloc; - } else if #[cfg(feature = "std")] { - extern crate std as alloc; - } -} - mod _epoch { pub extern crate crossbeam_epoch; } @@ -78,7 +72,7 @@ pub mod utils { } cfg_if! { - if #[cfg(any(feature = "std", feature = "alloc"))] { + if #[cfg(feature = "alloc")] { mod _queue { pub extern crate crossbeam_queue; }