Skip to content

Commit e35eb97

Browse files
bors[bot]taiki-e
andauthored
Merge #611
611: Make const_fn crate optional dependency r=taiki-e a=taiki-e This dependency is only actually used for the nightly feature. Co-authored-by: Taiki Endo <te316e89@gmail.com>
2 parents 207b96a + 54b0581 commit e35eb97

File tree

2 files changed

+11
-5
lines changed

2 files changed

+11
-5
lines changed

crossbeam-epoch/Cargo.toml

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -31,14 +31,14 @@ alloc = []
3131
# This is disabled by default and requires recent nightly compiler.
3232
# Note that this is outside of the normal semver guarantees and minor versions
3333
# of crossbeam may make breaking changes to them at any time.
34-
nightly = ["crossbeam-utils/nightly"]
34+
nightly = ["crossbeam-utils/nightly", "const_fn"]
3535

3636
# TODO: docs
3737
sanitize = [] # Makes it more likely to trigger any potential data races.
3838

3939
[dependencies]
4040
cfg-if = "1"
41-
const_fn = "0.4"
41+
const_fn = { version = "0.4.4", optional = true }
4242
memoffset = "0.6"
4343

4444
[dependencies.crossbeam-utils]

crossbeam-epoch/src/atomic.rs

Lines changed: 9 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -10,7 +10,6 @@ use core::sync::atomic::{AtomicUsize, Ordering};
1010
use crate::alloc::alloc;
1111
use crate::alloc::boxed::Box;
1212
use crate::guard::Guard;
13-
use const_fn::const_fn;
1413
use crossbeam_utils::atomic::AtomicConsume;
1514

1615
/// Given ordering for the success case in a compare-exchange operation, returns the strongest
@@ -327,8 +326,8 @@ impl<T: ?Sized + Pointable> Atomic<T> {
327326
/// let a = Atomic::<i32>::null();
328327
/// ```
329328
///
330-
#[const_fn(feature = "nightly")]
331-
pub const fn null() -> Atomic<T> {
329+
#[cfg_attr(feature = "nightly", const_fn::const_fn)]
330+
pub fn null() -> Atomic<T> {
332331
Self {
333332
data: AtomicUsize::new(0),
334333
_marker: PhantomData,
@@ -1371,4 +1370,11 @@ mod tests {
13711370
fn valid_tag_i64() {
13721371
Shared::<i64>::null().with_tag(7);
13731372
}
1373+
1374+
#[cfg(feature = "nightly")]
1375+
#[test]
1376+
fn const_atomic_null() {
1377+
use super::Atomic;
1378+
const _: Atomic<u8> = Atomic::<u8>::null();
1379+
}
13741380
}

0 commit comments

Comments
 (0)