Skip to content

Commit

Permalink
feature gate const-constructors to nightly
Browse files Browse the repository at this point in the history
they require feature(const_fn) which is not available on stable.
  • Loading branch information
mental32 committed Aug 24, 2020
1 parent e109288 commit 3d53e15
Show file tree
Hide file tree
Showing 6 changed files with 9 additions and 6 deletions.
5 changes: 4 additions & 1 deletion tokio/src/lib.rs
Expand Up @@ -17,7 +17,10 @@
))]
#![cfg_attr(docsrs, feature(doc_cfg))]
#![cfg_attr(docsrs, feature(doc_alias))]
#![cfg_attr(all(feature = "parking_lot", not(all(loom, test)),), feature(const_fn))]
#![cfg_attr(
all(feature = "nightly", feature = "parking_lot", not(all(loom, test))),
feature(const_fn)
)]

//! A runtime for writing reliable, asynchronous, and slim applications.
//!
Expand Down
2 changes: 1 addition & 1 deletion tokio/src/loom/std/atomic_usize.rs
Expand Up @@ -16,7 +16,7 @@ impl AtomicUsize {
AtomicUsize { inner }
}

#[cfg(all(feature = "parking_lot", not(all(loom, test)),))]
#[cfg(all(feature = "nightly", feature = "parking_lot", not(all(loom, test)),))]
pub(crate) const fn const_new(val: usize) -> AtomicUsize {
let inner = UnsafeCell::new(std::sync::atomic::AtomicUsize::new(val));
AtomicUsize { inner }
Expand Down
2 changes: 1 addition & 1 deletion tokio/src/loom/std/parking_lot.rs
Expand Up @@ -27,7 +27,7 @@ impl<T> Mutex<T> {
}

#[inline]
#[cfg(all(feature = "parking_lot", not(all(loom, test)),))]
#[cfg(all(feature = "nightly", feature = "parking_lot", not(all(loom, test)),))]
pub(crate) const fn const_new(t: T) -> Mutex<T> {
Mutex(parking_lot::const_mutex(t))
}
Expand Down
2 changes: 1 addition & 1 deletion tokio/src/sync/batch_semaphore.rs
Expand Up @@ -126,7 +126,7 @@ impl Semaphore {
/// Creates a new semaphore with the initial number of permits
///
/// Maximum number of permits on 32-bit platforms is `1<<29`.
#[cfg(all(feature = "parking_lot", not(all(loom, test)),))]
#[cfg(all(feature = "nightly", feature = "parking_lot", not(all(loom, test)),))]
pub(crate) const fn const_new(permits: usize) -> Self {
// FIXME: assertions and by extension panics are still being worked on: https://github.com/rust-lang/rust/issues/74925
Self {
Expand Down
2 changes: 1 addition & 1 deletion tokio/src/sync/mutex.rs
Expand Up @@ -228,7 +228,7 @@ impl<T: ?Sized> Mutex<T> {
///
/// static lock: Mutex<i32> = Mutex::const_new(5);
/// ```
#[cfg(all(feature = "parking_lot", not(all(loom, test)),))]
#[cfg(all(feature = "nightly", feature = "parking_lot", not(all(loom, test)),))]
pub const fn const_new(t: T) -> Self
where
T: Sized,
Expand Down
2 changes: 1 addition & 1 deletion tokio/src/util/linked_list.rs
Expand Up @@ -76,7 +76,7 @@ impl<T: Link> LinkedList<T> {
}

/// Creates an empty linked list
#[cfg(all(feature = "parking_lot", not(all(loom, test)),))]
#[cfg(all(feature = "nightly", feature = "parking_lot", not(all(loom, test)),))]
pub(crate) const fn const_new() -> LinkedList<T> {
LinkedList {
head: None,
Expand Down

0 comments on commit 3d53e15

Please sign in to comment.