From aa092c1aed371b01066803d2859fdad90506ea62 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Linus=20F=C3=A4rnstrand?= Date: Mon, 4 Mar 2019 17:57:03 +0100 Subject: [PATCH 1/9] Remove < Rust 1.25 support by using repr(align) --- core/build.rs | 3 --- core/src/parking_lot.rs | 10 +--------- 2 files changed, 1 insertion(+), 12 deletions(-) diff --git a/core/build.rs b/core/build.rs index 7cb883e3..8d745eef 100644 --- a/core/build.rs +++ b/core/build.rs @@ -2,9 +2,6 @@ extern crate rustc_version; use rustc_version::{version, Version}; fn main() { - if version().unwrap() >= Version::parse("1.25.0").unwrap() { - println!("cargo:rustc-cfg=has_repr_align"); - } if version().unwrap() >= Version::parse("1.26.0").unwrap() { println!("cargo:rustc-cfg=has_localkey_try_with"); } diff --git a/core/src/parking_lot.rs b/core/src/parking_lot.rs index ad40f1c2..3cccd3a4 100644 --- a/core/src/parking_lot.rs +++ b/core/src/parking_lot.rs @@ -50,7 +50,7 @@ impl HashTable { } } -#[cfg_attr(has_repr_align, repr(align(64)))] +#[repr(align(64))] struct Bucket { // Lock protecting the queue mutex: WordLock, @@ -61,12 +61,6 @@ struct Bucket { // Next time at which point be_fair should be set fair_timeout: UnsafeCell, - - // Padding to avoid false sharing between buckets. Ideally we would just - // align the bucket structure to 64 bytes, but Rust doesn't support that - // yet. Remove this field when dropping support for Rust < 1.25 - #[cfg(not(has_repr_align))] - _padding: [u8; 64], } impl Bucket { @@ -77,8 +71,6 @@ impl Bucket { queue_head: Cell::new(ptr::null()), queue_tail: Cell::new(ptr::null()), fair_timeout: UnsafeCell::new(FairTimeout::new()), - #[cfg(not(has_repr_align))] - _padding: unsafe { ::std::mem::uninitialized() }, } } } From 533d20ee73487f9cecf8e40ff793672b587ded3a Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Linus=20F=C3=A4rnstrand?= Date: Mon, 4 Mar 2019 18:01:34 +0100 Subject: [PATCH 2/9] Remove support for = Version::parse("1.26.0").unwrap() { - println!("cargo:rustc-cfg=has_localkey_try_with"); - } -} diff --git a/core/src/parking_lot.rs b/core/src/parking_lot.rs index 3cccd3a4..d11a30a4 100644 --- a/core/src/parking_lot.rs +++ b/core/src/parking_lot.rs @@ -9,11 +9,8 @@ use rand::rngs::SmallRng; use rand::{FromEntropy, Rng}; use smallvec::SmallVec; use std::cell::{Cell, UnsafeCell}; -#[cfg(not(has_localkey_try_with))] -use std::panic; use std::ptr; use std::sync::atomic::{AtomicPtr, AtomicUsize, Ordering}; -use std::thread::LocalKey; use std::time::{Duration, Instant}; use thread_parker::ThreadParker; use util::UncheckedOptionExt; @@ -165,24 +162,14 @@ fn with_thread_data(f: F) -> T where F: FnOnce(&ThreadData) -> T, { - // Try to read from thread-local storage, but return None if the TLS has - // already been destroyed. - #[cfg(has_localkey_try_with)] - fn try_get_tls(key: &'static LocalKey) -> Option<*const ThreadData> { - key.try_with(|x| x as *const ThreadData).ok() - } - #[cfg(not(has_localkey_try_with))] - fn try_get_tls(key: &'static LocalKey) -> Option<*const ThreadData> { - panic::catch_unwind(|| key.with(|x| x as *const ThreadData)).ok() - } - // Unlike word_lock::ThreadData, parking_lot::ThreadData is always expensive // to construct. Try to use a thread-local version if possible. Otherwise just // create a ThreadData on the stack let mut thread_data_storage = None; thread_local!(static THREAD_DATA: ThreadData = ThreadData::new()); - let thread_data_ptr = try_get_tls(&THREAD_DATA) - .unwrap_or_else(|| thread_data_storage.get_or_insert_with(ThreadData::new)); + let thread_data_ptr = THREAD_DATA + .try_with(|x| x as *const ThreadData) + .unwrap_or_else(|_| thread_data_storage.get_or_insert_with(ThreadData::new)); f(unsafe { &*thread_data_ptr }) } diff --git a/core/src/word_lock.rs b/core/src/word_lock.rs index fb632433..b365c8bb 100644 --- a/core/src/word_lock.rs +++ b/core/src/word_lock.rs @@ -8,11 +8,8 @@ use spinwait::SpinWait; use std::cell::Cell; use std::mem; -#[cfg(not(has_localkey_try_with))] -use std::panic; use std::ptr; use std::sync::atomic::{fence, AtomicUsize, Ordering}; -use std::thread::LocalKey; use thread_parker::ThreadParker; struct ThreadData { @@ -54,23 +51,12 @@ fn with_thread_data(f: F) -> T where F: FnOnce(&ThreadData) -> T, { - // Try to read from thread-local storage, but return None if the TLS has - // already been destroyed. - #[cfg(has_localkey_try_with)] - fn try_get_tls(key: &'static LocalKey) -> Option<*const ThreadData> { - key.try_with(|x| x as *const ThreadData).ok() - } - #[cfg(not(has_localkey_try_with))] - fn try_get_tls(key: &'static LocalKey) -> Option<*const ThreadData> { - panic::catch_unwind(|| key.with(|x| x as *const ThreadData)).ok() - } - let mut thread_data_ptr = ptr::null(); // If ThreadData is expensive to construct, then we want to use a cached // version in thread-local storage if possible. if !ThreadParker::IS_CHEAP_TO_CONSTRUCT { thread_local!(static THREAD_DATA: ThreadData = ThreadData::new()); - if let Some(tls_thread_data) = try_get_tls(&THREAD_DATA) { + if let Ok(tls_thread_data) = THREAD_DATA.try_with(|x| x as *const ThreadData) { thread_data_ptr = tls_thread_data; } } From 0b6911698b02f4860dfe9af72cbdc06e6ab72018 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Linus=20F=C3=A4rnstrand?= Date: Mon, 4 Mar 2019 18:07:15 +0100 Subject: [PATCH 3/9] Disable the owning_ref feature by default --- Cargo.toml | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/Cargo.toml b/Cargo.toml index 8351f865..bf0d8206 100644 --- a/Cargo.toml +++ b/Cargo.toml @@ -18,7 +18,7 @@ rand = "0.6" lazy_static = "1.0" [features] -default = ["owning_ref"] +default = [] owning_ref = ["lock_api/owning_ref"] nightly = ["parking_lot_core/nightly", "lock_api/nightly"] deadlock_detection = ["parking_lot_core/deadlock_detection"] From 28bf1aae07e453fa9acd675a4a6e469b28df7ff8 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Linus=20F=C3=A4rnstrand?= Date: Mon, 4 Mar 2019 18:09:31 +0100 Subject: [PATCH 4/9] Upgrade to Rust 2018 --- Cargo.toml | 1 + core/Cargo.toml | 1 + core/src/lib.rs | 28 +++------- core/src/parking_lot.rs | 8 +-- core/src/spinwait.rs | 2 +- core/src/thread_parker/windows/mod.rs | 1 - core/src/word_lock.rs | 4 +- lock_api/Cargo.toml | 1 + lock_api/src/lib.rs | 9 ++-- lock_api/src/mutex.rs | 26 ++++----- lock_api/src/remutex.rs | 30 +++++------ lock_api/src/rwlock.rs | 78 ++++++++++++++------------- src/condvar.rs | 20 +++---- src/deadlock.rs | 4 +- src/lib.rs | 24 ++++----- src/mutex.rs | 4 +- src/once.rs | 8 +-- src/raw_mutex.rs | 4 +- src/raw_rwlock.rs | 6 +-- src/remutex.rs | 4 +- src/rwlock.rs | 7 ++- 21 files changed, 127 insertions(+), 143 deletions(-) diff --git a/Cargo.toml b/Cargo.toml index bf0d8206..1cce9475 100644 --- a/Cargo.toml +++ b/Cargo.toml @@ -8,6 +8,7 @@ repository = "https://github.com/Amanieu/parking_lot" readme = "README.md" keywords = ["mutex", "condvar", "rwlock", "once", "thread"] categories = ["concurrency"] +edition = "2018" [dependencies] parking_lot_core = { path = "core", version = "0.4" } diff --git a/core/Cargo.toml b/core/Cargo.toml index e489d9d6..90c95da4 100644 --- a/core/Cargo.toml +++ b/core/Cargo.toml @@ -7,6 +7,7 @@ license = "Apache-2.0/MIT" repository = "https://github.com/Amanieu/parking_lot" keywords = ["mutex", "condvar", "rwlock", "once", "thread"] categories = ["concurrency"] +edition = "2018" [dependencies] smallvec = "0.6" diff --git a/core/src/lib.rs b/core/src/lib.rs index 338b63e9..3ae0ab41 100644 --- a/core/src/lib.rs +++ b/core/src/lib.rs @@ -43,22 +43,6 @@ feature(integer_atomics) )] -extern crate rand; -extern crate smallvec; - -#[cfg(feature = "deadlock_detection")] -extern crate backtrace; -#[cfg(feature = "deadlock_detection")] -extern crate petgraph; -#[cfg(feature = "deadlock_detection")] -extern crate thread_id; - -#[cfg(unix)] -extern crate libc; - -#[cfg(windows)] -extern crate winapi; - #[cfg(all(feature = "nightly", target_os = "linux"))] #[path = "thread_parker/linux.rs"] mod thread_parker; @@ -77,8 +61,10 @@ mod spinwait; mod util; mod word_lock; -pub use parking_lot::deadlock; -pub use parking_lot::{park, unpark_all, unpark_filter, unpark_one, unpark_requeue}; -pub use parking_lot::{FilterOp, ParkResult, ParkToken, RequeueOp, UnparkResult, UnparkToken}; -pub use parking_lot::{DEFAULT_PARK_TOKEN, DEFAULT_UNPARK_TOKEN}; -pub use spinwait::SpinWait; +pub use self::parking_lot::deadlock; +pub use self::parking_lot::{park, unpark_all, unpark_filter, unpark_one, unpark_requeue}; +pub use self::parking_lot::{ + FilterOp, ParkResult, ParkToken, RequeueOp, UnparkResult, UnparkToken, +}; +pub use self::parking_lot::{DEFAULT_PARK_TOKEN, DEFAULT_UNPARK_TOKEN}; +pub use self::spinwait::SpinWait; diff --git a/core/src/parking_lot.rs b/core/src/parking_lot.rs index d11a30a4..791da994 100644 --- a/core/src/parking_lot.rs +++ b/core/src/parking_lot.rs @@ -5,6 +5,9 @@ // http://opensource.org/licenses/MIT>, at your option. This file may not be // copied, modified, or distributed except according to those terms. +use crate::thread_parker::ThreadParker; +use crate::util::UncheckedOptionExt; +use crate::word_lock::WordLock; use rand::rngs::SmallRng; use rand::{FromEntropy, Rng}; use smallvec::SmallVec; @@ -12,9 +15,6 @@ use std::cell::{Cell, UnsafeCell}; use std::ptr; use std::sync::atomic::{AtomicPtr, AtomicUsize, Ordering}; use std::time::{Duration, Instant}; -use thread_parker::ThreadParker; -use util::UncheckedOptionExt; -use word_lock::WordLock; static NUM_THREADS: AtomicUsize = AtomicUsize::new(0); static HASHTABLE: AtomicPtr = AtomicPtr::new(ptr::null_mut()); @@ -1085,6 +1085,7 @@ pub mod deadlock { #[cfg(feature = "deadlock_detection")] mod deadlock_impl { use super::{get_hashtable, lock_bucket, with_thread_data, ThreadData, NUM_THREADS}; + use crate::word_lock::WordLock; use backtrace::Backtrace; use petgraph; use petgraph::graphmap::DiGraphMap; @@ -1093,7 +1094,6 @@ mod deadlock_impl { use std::sync::atomic::Ordering; use std::sync::mpsc; use thread_id; - use word_lock::WordLock; /// Representation of a deadlocked thread pub struct DeadlockedThread { diff --git a/core/src/spinwait.rs b/core/src/spinwait.rs index 6912d43b..ad0327a3 100644 --- a/core/src/spinwait.rs +++ b/core/src/spinwait.rs @@ -5,8 +5,8 @@ // http://opensource.org/licenses/MIT>, at your option. This file may not be // copied, modified, or distributed except according to those terms. +use crate::thread_parker; use std::sync::atomic::spin_loop_hint; -use thread_parker; // Wastes some CPU time for the given number of iterations, // using a hint to indicate to the CPU that we are spinning. diff --git a/core/src/thread_parker/windows/mod.rs b/core/src/thread_parker/windows/mod.rs index 537501d3..7e17dec2 100644 --- a/core/src/thread_parker/windows/mod.rs +++ b/core/src/thread_parker/windows/mod.rs @@ -8,7 +8,6 @@ use std::ptr; use std::sync::atomic::{AtomicPtr, AtomicUsize, Ordering}; use std::time::Instant; -use winapi; mod keyed_event; mod waitaddress; diff --git a/core/src/word_lock.rs b/core/src/word_lock.rs index b365c8bb..054144e9 100644 --- a/core/src/word_lock.rs +++ b/core/src/word_lock.rs @@ -5,12 +5,12 @@ // http://opensource.org/licenses/MIT>, at your option. This file may not be // copied, modified, or distributed except according to those terms. -use spinwait::SpinWait; +use crate::spinwait::SpinWait; +use crate::thread_parker::ThreadParker; use std::cell::Cell; use std::mem; use std::ptr; use std::sync::atomic::{fence, AtomicUsize, Ordering}; -use thread_parker::ThreadParker; struct ThreadData { parker: ThreadParker, diff --git a/lock_api/Cargo.toml b/lock_api/Cargo.toml index 0b009d66..75b767aa 100644 --- a/lock_api/Cargo.toml +++ b/lock_api/Cargo.toml @@ -7,6 +7,7 @@ license = "Apache-2.0/MIT" repository = "https://github.com/Amanieu/parking_lot" keywords = ["mutex", "rwlock", "lock", "no_std"] categories = ["concurrency", "no-std"] +edition = "2018" [dependencies] scopeguard = { version = "1.0", default-features = false } diff --git a/lock_api/src/lib.rs b/lock_api/src/lib.rs index c53e2fe9..0eb8a563 100644 --- a/lock_api/src/lib.rs +++ b/lock_api/src/lib.rs @@ -90,9 +90,6 @@ #[macro_use] extern crate scopeguard; -#[cfg(feature = "owning_ref")] -extern crate owning_ref; - /// Marker type which indicates that the Guard type for a lock is `Send`. pub struct GuardSend(()); @@ -100,10 +97,10 @@ pub struct GuardSend(()); pub struct GuardNoSend(*mut ()); mod mutex; -pub use mutex::*; +pub use crate::mutex::*; mod remutex; -pub use remutex::*; +pub use crate::remutex::*; mod rwlock; -pub use rwlock::*; +pub use crate::rwlock::*; diff --git a/lock_api/src/mutex.rs b/lock_api/src/mutex.rs index b643dac9..7e05fbab 100644 --- a/lock_api/src/mutex.rs +++ b/lock_api/src/mutex.rs @@ -127,7 +127,7 @@ impl Mutex { impl Mutex { #[inline] - fn guard(&self) -> MutexGuard { + fn guard(&self) -> MutexGuard<'_, R, T> { MutexGuard { mutex: self, marker: PhantomData, @@ -144,7 +144,7 @@ impl Mutex { /// Attempts to lock a mutex in the thread which already holds the lock will /// result in a deadlock. #[inline] - pub fn lock(&self) -> MutexGuard { + pub fn lock(&self) -> MutexGuard<'_, R, T> { self.raw.lock(); self.guard() } @@ -157,7 +157,7 @@ impl Mutex { /// /// This function does not block. #[inline] - pub fn try_lock(&self) -> Option> { + pub fn try_lock(&self) -> Option> { if self.raw.try_lock() { Some(self.guard()) } else { @@ -230,7 +230,7 @@ impl Mutex { /// `None` is returned. Otherwise, an RAII guard is returned. The lock will /// be unlocked when the guard is dropped. #[inline] - pub fn try_lock_for(&self, timeout: R::Duration) -> Option> { + pub fn try_lock_for(&self, timeout: R::Duration) -> Option> { if self.raw.try_lock_for(timeout) { Some(self.guard()) } else { @@ -244,7 +244,7 @@ impl Mutex { /// `None` is returned. Otherwise, an RAII guard is returned. The lock will /// be unlocked when the guard is dropped. #[inline] - pub fn try_lock_until(&self, timeout: R::Instant) -> Option> { + pub fn try_lock_until(&self, timeout: R::Instant) -> Option> { if self.raw.try_lock_until(timeout) { Some(self.guard()) } else { @@ -268,13 +268,13 @@ impl From for Mutex { } impl fmt::Debug for Mutex { - fn fmt(&self, f: &mut fmt::Formatter) -> fmt::Result { + fn fmt(&self, f: &mut fmt::Formatter<'_>) -> fmt::Result { match self.try_lock() { Some(guard) => f.debug_struct("Mutex").field("data", &&*guard).finish(), None => { struct LockedPlaceholder; impl fmt::Debug for LockedPlaceholder { - fn fmt(&self, f: &mut fmt::Formatter) -> fmt::Result { + fn fmt(&self, f: &mut fmt::Formatter<'_>) -> fmt::Result { f.write_str("") } } @@ -293,7 +293,7 @@ impl fmt::Debug for Mutex { /// The data protected by the mutex can be accessed through this guard via its /// `Deref` and `DerefMut` implementations. #[must_use = "if unused the Mutex will immediately unlock"] -pub struct MutexGuard<'a, R: RawMutex + 'a, T: ?Sized + 'a> { +pub struct MutexGuard<'a, R: RawMutex, T: ?Sized> { mutex: &'a Mutex, marker: PhantomData<(&'a mut T, R::GuardMarker)>, } @@ -440,13 +440,13 @@ impl<'a, R: RawMutex + 'a, T: ?Sized + 'a> Drop for MutexGuard<'a, R, T> { } impl<'a, R: RawMutex + 'a, T: fmt::Debug + ?Sized + 'a> fmt::Debug for MutexGuard<'a, R, T> { - fn fmt(&self, f: &mut fmt::Formatter) -> fmt::Result { + fn fmt(&self, f: &mut fmt::Formatter<'_>) -> fmt::Result { fmt::Debug::fmt(&**self, f) } } impl<'a, R: RawMutex + 'a, T: fmt::Display + ?Sized + 'a> fmt::Display for MutexGuard<'a, R, T> { - fn fmt(&self, f: &mut fmt::Formatter) -> fmt::Result { + fn fmt(&self, f: &mut fmt::Formatter<'_>) -> fmt::Result { (**self).fmt(f) } } @@ -462,7 +462,7 @@ unsafe impl<'a, R: RawMutex + 'a, T: ?Sized + 'a> StableAddress for MutexGuard<' /// could introduce soundness issues if the locked object is modified by another /// thread. #[must_use = "if unused the Mutex will immediately unlock"] -pub struct MappedMutexGuard<'a, R: RawMutex + 'a, T: ?Sized + 'a> { +pub struct MappedMutexGuard<'a, R: RawMutex, T: ?Sized> { raw: &'a R, data: *mut T, marker: PhantomData<&'a mut T>, @@ -572,7 +572,7 @@ impl<'a, R: RawMutex + 'a, T: ?Sized + 'a> Drop for MappedMutexGuard<'a, R, T> { } impl<'a, R: RawMutex + 'a, T: fmt::Debug + ?Sized + 'a> fmt::Debug for MappedMutexGuard<'a, R, T> { - fn fmt(&self, f: &mut fmt::Formatter) -> fmt::Result { + fn fmt(&self, f: &mut fmt::Formatter<'_>) -> fmt::Result { fmt::Debug::fmt(&**self, f) } } @@ -580,7 +580,7 @@ impl<'a, R: RawMutex + 'a, T: fmt::Debug + ?Sized + 'a> fmt::Debug for MappedMut impl<'a, R: RawMutex + 'a, T: fmt::Display + ?Sized + 'a> fmt::Display for MappedMutexGuard<'a, R, T> { - fn fmt(&self, f: &mut fmt::Formatter) -> fmt::Result { + fn fmt(&self, f: &mut fmt::Formatter<'_>) -> fmt::Result { (**self).fmt(f) } } diff --git a/lock_api/src/remutex.rs b/lock_api/src/remutex.rs index e2dfdd88..6b49ba23 100644 --- a/lock_api/src/remutex.rs +++ b/lock_api/src/remutex.rs @@ -5,14 +5,14 @@ // http://opensource.org/licenses/MIT>, at your option. This file may not be // copied, modified, or distributed except according to those terms. +use crate::mutex::{RawMutex, RawMutexFair, RawMutexTimed}; +use crate::GuardNoSend; use core::cell::{Cell, UnsafeCell}; use core::fmt; use core::marker::PhantomData; use core::mem; use core::ops::Deref; use core::sync::atomic::{AtomicUsize, Ordering}; -use mutex::{RawMutex, RawMutexFair, RawMutexTimed}; -use GuardNoSend; #[cfg(feature = "owning_ref")] use owning_ref::StableAddress; @@ -190,7 +190,7 @@ impl ReentrantMutex { impl ReentrantMutex { #[inline] - fn guard(&self) -> ReentrantMutexGuard { + fn guard(&self) -> ReentrantMutexGuard<'_, R, G, T> { ReentrantMutexGuard { remutex: &self, marker: PhantomData, @@ -208,7 +208,7 @@ impl ReentrantMutex { /// returned to allow scoped unlock of the lock. When the guard goes out of /// scope, the mutex will be unlocked. #[inline] - pub fn lock(&self) -> ReentrantMutexGuard { + pub fn lock(&self) -> ReentrantMutexGuard<'_, R, G, T> { self.raw.lock(); self.guard() } @@ -221,7 +221,7 @@ impl ReentrantMutex { /// /// This function does not block. #[inline] - pub fn try_lock(&self) -> Option> { + pub fn try_lock(&self) -> Option> { if self.raw.try_lock() { Some(self.guard()) } else { @@ -294,7 +294,7 @@ impl ReentrantMutex { /// `None` is returned. Otherwise, an RAII guard is returned. The lock will /// be unlocked when the guard is dropped. #[inline] - pub fn try_lock_for(&self, timeout: R::Duration) -> Option> { + pub fn try_lock_for(&self, timeout: R::Duration) -> Option> { if self.raw.try_lock_for(timeout) { Some(self.guard()) } else { @@ -308,7 +308,7 @@ impl ReentrantMutex { /// `None` is returned. Otherwise, an RAII guard is returned. The lock will /// be unlocked when the guard is dropped. #[inline] - pub fn try_lock_until(&self, timeout: R::Instant) -> Option> { + pub fn try_lock_until(&self, timeout: R::Instant) -> Option> { if self.raw.try_lock_until(timeout) { Some(self.guard()) } else { @@ -332,7 +332,7 @@ impl From for ReentrantMutex { } impl fmt::Debug for ReentrantMutex { - fn fmt(&self, f: &mut fmt::Formatter) -> fmt::Result { + fn fmt(&self, f: &mut fmt::Formatter<'_>) -> fmt::Result { match self.try_lock() { Some(guard) => f .debug_struct("ReentrantMutex") @@ -341,7 +341,7 @@ impl fmt::Debug for Reentra None => { struct LockedPlaceholder; impl fmt::Debug for LockedPlaceholder { - fn fmt(&self, f: &mut fmt::Formatter) -> fmt::Result { + fn fmt(&self, f: &mut fmt::Formatter<'_>) -> fmt::Result { f.write_str("") } } @@ -360,7 +360,7 @@ impl fmt::Debug for Reentra /// The data protected by the mutex can be accessed through this guard via its /// `Deref` implementation. #[must_use = "if unused the ReentrantMutex will immediately unlock"] -pub struct ReentrantMutexGuard<'a, R: RawMutex + 'a, G: GetThreadId + 'a, T: ?Sized + 'a> { +pub struct ReentrantMutexGuard<'a, R: RawMutex, G: GetThreadId, T: ?Sized> { remutex: &'a ReentrantMutex, marker: PhantomData<(&'a T, GuardNoSend)>, } @@ -514,7 +514,7 @@ impl<'a, R: RawMutex + 'a, G: GetThreadId + 'a, T: ?Sized + 'a> Drop impl<'a, R: RawMutex + 'a, G: GetThreadId + 'a, T: fmt::Debug + ?Sized + 'a> fmt::Debug for ReentrantMutexGuard<'a, R, G, T> { - fn fmt(&self, f: &mut fmt::Formatter) -> fmt::Result { + fn fmt(&self, f: &mut fmt::Formatter<'_>) -> fmt::Result { fmt::Debug::fmt(&**self, f) } } @@ -522,7 +522,7 @@ impl<'a, R: RawMutex + 'a, G: GetThreadId + 'a, T: fmt::Debug + ?Sized + 'a> fmt impl<'a, R: RawMutex + 'a, G: GetThreadId + 'a, T: fmt::Display + ?Sized + 'a> fmt::Display for ReentrantMutexGuard<'a, R, G, T> { - fn fmt(&self, f: &mut fmt::Formatter) -> fmt::Result { + fn fmt(&self, f: &mut fmt::Formatter<'_>) -> fmt::Result { (**self).fmt(f) } } @@ -541,7 +541,7 @@ unsafe impl<'a, R: RawMutex + 'a, G: GetThreadId + 'a, T: ?Sized + 'a> StableAdd /// could introduce soundness issues if the locked object is modified by another /// thread. #[must_use = "if unused the ReentrantMutex will immediately unlock"] -pub struct MappedReentrantMutexGuard<'a, R: RawMutex + 'a, G: GetThreadId + 'a, T: ?Sized + 'a> { +pub struct MappedReentrantMutexGuard<'a, R: RawMutex, G: GetThreadId, T: ?Sized> { raw: &'a RawReentrantMutex, data: *const T, marker: PhantomData<&'a T>, @@ -653,7 +653,7 @@ impl<'a, R: RawMutex + 'a, G: GetThreadId + 'a, T: ?Sized + 'a> Drop impl<'a, R: RawMutex + 'a, G: GetThreadId + 'a, T: fmt::Debug + ?Sized + 'a> fmt::Debug for MappedReentrantMutexGuard<'a, R, G, T> { - fn fmt(&self, f: &mut fmt::Formatter) -> fmt::Result { + fn fmt(&self, f: &mut fmt::Formatter<'_>) -> fmt::Result { fmt::Debug::fmt(&**self, f) } } @@ -661,7 +661,7 @@ impl<'a, R: RawMutex + 'a, G: GetThreadId + 'a, T: fmt::Debug + ?Sized + 'a> fmt impl<'a, R: RawMutex + 'a, G: GetThreadId + 'a, T: fmt::Display + ?Sized + 'a> fmt::Display for MappedReentrantMutexGuard<'a, R, G, T> { - fn fmt(&self, f: &mut fmt::Formatter) -> fmt::Result { + fn fmt(&self, f: &mut fmt::Formatter<'_>) -> fmt::Result { (**self).fmt(f) } } diff --git a/lock_api/src/rwlock.rs b/lock_api/src/rwlock.rs index d32998d6..18bafd6f 100644 --- a/lock_api/src/rwlock.rs +++ b/lock_api/src/rwlock.rs @@ -264,7 +264,7 @@ impl RwLock { impl RwLock { #[inline] - fn read_guard(&self) -> RwLockReadGuard { + fn read_guard(&self) -> RwLockReadGuard<'_, R, T> { RwLockReadGuard { rwlock: self, marker: PhantomData, @@ -272,7 +272,7 @@ impl RwLock { } #[inline] - fn write_guard(&self) -> RwLockWriteGuard { + fn write_guard(&self) -> RwLockWriteGuard<'_, R, T> { RwLockWriteGuard { rwlock: self, marker: PhantomData, @@ -292,7 +292,7 @@ impl RwLock { /// Returns an RAII guard which will release this thread's shared access /// once it is dropped. #[inline] - pub fn read(&self) -> RwLockReadGuard { + pub fn read(&self) -> RwLockReadGuard<'_, R, T> { self.raw.lock_shared(); self.read_guard() } @@ -305,7 +305,7 @@ impl RwLock { /// /// This function does not block. #[inline] - pub fn try_read(&self) -> Option> { + pub fn try_read(&self) -> Option> { if self.raw.try_lock_shared() { Some(self.read_guard()) } else { @@ -322,7 +322,7 @@ impl RwLock { /// Returns an RAII guard which will drop the write access of this `RwLock` /// when dropped. #[inline] - pub fn write(&self) -> RwLockWriteGuard { + pub fn write(&self) -> RwLockWriteGuard<'_, R, T> { self.raw.lock_exclusive(); self.write_guard() } @@ -335,7 +335,7 @@ impl RwLock { /// /// This function does not block. #[inline] - pub fn try_write(&self) -> Option> { + pub fn try_write(&self) -> Option> { if self.raw.try_lock_exclusive() { Some(self.write_guard()) } else { @@ -441,7 +441,7 @@ impl RwLock { /// `None` is returned. Otherwise, an RAII guard is returned which will /// release the shared access when it is dropped. #[inline] - pub fn try_read_for(&self, timeout: R::Duration) -> Option> { + pub fn try_read_for(&self, timeout: R::Duration) -> Option> { if self.raw.try_lock_shared_for(timeout) { Some(self.read_guard()) } else { @@ -456,7 +456,7 @@ impl RwLock { /// `None` is returned. Otherwise, an RAII guard is returned which will /// release the shared access when it is dropped. #[inline] - pub fn try_read_until(&self, timeout: R::Instant) -> Option> { + pub fn try_read_until(&self, timeout: R::Instant) -> Option> { if self.raw.try_lock_shared_until(timeout) { Some(self.read_guard()) } else { @@ -471,7 +471,7 @@ impl RwLock { /// `None` is returned. Otherwise, an RAII guard is returned which will /// release the exclusive access when it is dropped. #[inline] - pub fn try_write_for(&self, timeout: R::Duration) -> Option> { + pub fn try_write_for(&self, timeout: R::Duration) -> Option> { if self.raw.try_lock_exclusive_for(timeout) { Some(self.write_guard()) } else { @@ -486,7 +486,7 @@ impl RwLock { /// `None` is returned. Otherwise, an RAII guard is returned which will /// release the exclusive access when it is dropped. #[inline] - pub fn try_write_until(&self, timeout: R::Instant) -> Option> { + pub fn try_write_until(&self, timeout: R::Instant) -> Option> { if self.raw.try_lock_exclusive_until(timeout) { Some(self.write_guard()) } else { @@ -512,7 +512,7 @@ impl RwLock { /// Returns an RAII guard which will release this thread's shared access /// once it is dropped. #[inline] - pub fn read_recursive(&self) -> RwLockReadGuard { + pub fn read_recursive(&self) -> RwLockReadGuard<'_, R, T> { self.raw.lock_shared_recursive(); self.read_guard() } @@ -528,7 +528,7 @@ impl RwLock { /// /// This function does not block. #[inline] - pub fn try_read_recursive(&self) -> Option> { + pub fn try_read_recursive(&self) -> Option> { if self.raw.try_lock_shared_recursive() { Some(self.read_guard()) } else { @@ -549,7 +549,10 @@ impl RwLock { /// lock is held at the time of the call. See the documentation for /// `read_recursive` for details. #[inline] - pub fn try_read_recursive_for(&self, timeout: R::Duration) -> Option> { + pub fn try_read_recursive_for( + &self, + timeout: R::Duration, + ) -> Option> { if self.raw.try_lock_shared_recursive_for(timeout) { Some(self.read_guard()) } else { @@ -564,7 +567,10 @@ impl RwLock { /// `None` is returned. Otherwise, an RAII guard is returned which will /// release the shared access when it is dropped. #[inline] - pub fn try_read_recursive_until(&self, timeout: R::Instant) -> Option> { + pub fn try_read_recursive_until( + &self, + timeout: R::Instant, + ) -> Option> { if self.raw.try_lock_shared_recursive_until(timeout) { Some(self.read_guard()) } else { @@ -575,7 +581,7 @@ impl RwLock { impl RwLock { #[inline] - fn upgradable_guard(&self) -> RwLockUpgradableReadGuard { + fn upgradable_guard(&self) -> RwLockUpgradableReadGuard<'_, R, T> { RwLockUpgradableReadGuard { rwlock: self, marker: PhantomData, @@ -592,7 +598,7 @@ impl RwLock { /// Returns an RAII guard which will release this thread's shared access /// once it is dropped. #[inline] - pub fn upgradable_read(&self) -> RwLockUpgradableReadGuard { + pub fn upgradable_read(&self) -> RwLockUpgradableReadGuard<'_, R, T> { self.raw.lock_upgradable(); self.upgradable_guard() } @@ -605,7 +611,7 @@ impl RwLock { /// /// This function does not block. #[inline] - pub fn try_upgradable_read(&self) -> Option> { + pub fn try_upgradable_read(&self) -> Option> { if self.raw.try_lock_upgradable() { Some(self.upgradable_guard()) } else { @@ -625,7 +631,7 @@ impl RwLock { pub fn try_upgradable_read_for( &self, timeout: R::Duration, - ) -> Option> { + ) -> Option> { if self.raw.try_lock_upgradable_for(timeout) { Some(self.upgradable_guard()) } else { @@ -643,7 +649,7 @@ impl RwLock { pub fn try_upgradable_read_until( &self, timeout: R::Instant, - ) -> Option> { + ) -> Option> { if self.raw.try_lock_upgradable_until(timeout) { Some(self.upgradable_guard()) } else { @@ -667,13 +673,13 @@ impl From for RwLock { } impl fmt::Debug for RwLock { - fn fmt(&self, f: &mut fmt::Formatter) -> fmt::Result { + fn fmt(&self, f: &mut fmt::Formatter<'_>) -> fmt::Result { match self.try_read() { Some(guard) => f.debug_struct("RwLock").field("data", &&*guard).finish(), None => { struct LockedPlaceholder; impl fmt::Debug for LockedPlaceholder { - fn fmt(&self, f: &mut fmt::Formatter) -> fmt::Result { + fn fmt(&self, f: &mut fmt::Formatter<'_>) -> fmt::Result { f.write_str("") } } @@ -689,7 +695,7 @@ impl fmt::Debug for RwLock { /// RAII structure used to release the shared read access of a lock when /// dropped. #[must_use = "if unused the RwLock will immediately unlock"] -pub struct RwLockReadGuard<'a, R: RawRwLock + 'a, T: ?Sized + 'a> { +pub struct RwLockReadGuard<'a, R: RawRwLock, T: ?Sized> { rwlock: &'a RwLock, marker: PhantomData<(&'a T, R::GuardMarker)>, } @@ -831,7 +837,7 @@ impl<'a, R: RawRwLock + 'a, T: ?Sized + 'a> Drop for RwLockReadGuard<'a, R, T> { } impl<'a, R: RawRwLock + 'a, T: fmt::Debug + ?Sized + 'a> fmt::Debug for RwLockReadGuard<'a, R, T> { - fn fmt(&self, f: &mut fmt::Formatter) -> fmt::Result { + fn fmt(&self, f: &mut fmt::Formatter<'_>) -> fmt::Result { fmt::Debug::fmt(&**self, f) } } @@ -839,7 +845,7 @@ impl<'a, R: RawRwLock + 'a, T: fmt::Debug + ?Sized + 'a> fmt::Debug for RwLockRe impl<'a, R: RawRwLock + 'a, T: fmt::Display + ?Sized + 'a> fmt::Display for RwLockReadGuard<'a, R, T> { - fn fmt(&self, f: &mut fmt::Formatter) -> fmt::Result { + fn fmt(&self, f: &mut fmt::Formatter<'_>) -> fmt::Result { (**self).fmt(f) } } @@ -850,7 +856,7 @@ unsafe impl<'a, R: RawRwLock + 'a, T: ?Sized + 'a> StableAddress for RwLockReadG /// RAII structure used to release the exclusive write access of a lock when /// dropped. #[must_use = "if unused the RwLock will immediately unlock"] -pub struct RwLockWriteGuard<'a, R: RawRwLock + 'a, T: ?Sized + 'a> { +pub struct RwLockWriteGuard<'a, R: RawRwLock, T: ?Sized> { rwlock: &'a RwLock, marker: PhantomData<(&'a mut T, R::GuardMarker)>, } @@ -1033,7 +1039,7 @@ impl<'a, R: RawRwLock + 'a, T: ?Sized + 'a> Drop for RwLockWriteGuard<'a, R, T> } impl<'a, R: RawRwLock + 'a, T: fmt::Debug + ?Sized + 'a> fmt::Debug for RwLockWriteGuard<'a, R, T> { - fn fmt(&self, f: &mut fmt::Formatter) -> fmt::Result { + fn fmt(&self, f: &mut fmt::Formatter<'_>) -> fmt::Result { fmt::Debug::fmt(&**self, f) } } @@ -1041,7 +1047,7 @@ impl<'a, R: RawRwLock + 'a, T: fmt::Debug + ?Sized + 'a> fmt::Debug for RwLockWr impl<'a, R: RawRwLock + 'a, T: fmt::Display + ?Sized + 'a> fmt::Display for RwLockWriteGuard<'a, R, T> { - fn fmt(&self, f: &mut fmt::Formatter) -> fmt::Result { + fn fmt(&self, f: &mut fmt::Formatter<'_>) -> fmt::Result { (**self).fmt(f) } } @@ -1052,7 +1058,7 @@ unsafe impl<'a, R: RawRwLock + 'a, T: ?Sized + 'a> StableAddress for RwLockWrite /// RAII structure used to release the upgradable read access of a lock when /// dropped. #[must_use = "if unused the RwLock will immediately unlock"] -pub struct RwLockUpgradableReadGuard<'a, R: RawRwLockUpgrade + 'a, T: ?Sized + 'a> { +pub struct RwLockUpgradableReadGuard<'a, R: RawRwLockUpgrade, T: ?Sized> { rwlock: &'a RwLock, marker: PhantomData<(&'a T, R::GuardMarker)>, } @@ -1239,7 +1245,7 @@ impl<'a, R: RawRwLockUpgrade + 'a, T: ?Sized + 'a> Drop for RwLockUpgradableRead impl<'a, R: RawRwLockUpgrade + 'a, T: fmt::Debug + ?Sized + 'a> fmt::Debug for RwLockUpgradableReadGuard<'a, R, T> { - fn fmt(&self, f: &mut fmt::Formatter) -> fmt::Result { + fn fmt(&self, f: &mut fmt::Formatter<'_>) -> fmt::Result { fmt::Debug::fmt(&**self, f) } } @@ -1247,7 +1253,7 @@ impl<'a, R: RawRwLockUpgrade + 'a, T: fmt::Debug + ?Sized + 'a> fmt::Debug impl<'a, R: RawRwLockUpgrade + 'a, T: fmt::Display + ?Sized + 'a> fmt::Display for RwLockUpgradableReadGuard<'a, R, T> { - fn fmt(&self, f: &mut fmt::Formatter) -> fmt::Result { + fn fmt(&self, f: &mut fmt::Formatter<'_>) -> fmt::Result { (**self).fmt(f) } } @@ -1266,7 +1272,7 @@ unsafe impl<'a, R: RawRwLockUpgrade + 'a, T: ?Sized + 'a> StableAddress /// could introduce soundness issues if the locked object is modified by another /// thread. #[must_use = "if unused the RwLock will immediately unlock"] -pub struct MappedRwLockReadGuard<'a, R: RawRwLock + 'a, T: ?Sized + 'a> { +pub struct MappedRwLockReadGuard<'a, R: RawRwLock, T: ?Sized> { raw: &'a R, data: *const T, marker: PhantomData<&'a T>, @@ -1368,7 +1374,7 @@ impl<'a, R: RawRwLock + 'a, T: ?Sized + 'a> Drop for MappedRwLockReadGuard<'a, R impl<'a, R: RawRwLock + 'a, T: fmt::Debug + ?Sized + 'a> fmt::Debug for MappedRwLockReadGuard<'a, R, T> { - fn fmt(&self, f: &mut fmt::Formatter) -> fmt::Result { + fn fmt(&self, f: &mut fmt::Formatter<'_>) -> fmt::Result { fmt::Debug::fmt(&**self, f) } } @@ -1376,7 +1382,7 @@ impl<'a, R: RawRwLock + 'a, T: fmt::Debug + ?Sized + 'a> fmt::Debug impl<'a, R: RawRwLock + 'a, T: fmt::Display + ?Sized + 'a> fmt::Display for MappedRwLockReadGuard<'a, R, T> { - fn fmt(&self, f: &mut fmt::Formatter) -> fmt::Result { + fn fmt(&self, f: &mut fmt::Formatter<'_>) -> fmt::Result { (**self).fmt(f) } } @@ -1395,7 +1401,7 @@ unsafe impl<'a, R: RawRwLock + 'a, T: ?Sized + 'a> StableAddress /// could introduce soundness issues if the locked object is modified by another /// thread. #[must_use = "if unused the RwLock will immediately unlock"] -pub struct MappedRwLockWriteGuard<'a, R: RawRwLock + 'a, T: ?Sized + 'a> { +pub struct MappedRwLockWriteGuard<'a, R: RawRwLock, T: ?Sized> { raw: &'a R, data: *mut T, marker: PhantomData<&'a mut T>, @@ -1527,7 +1533,7 @@ impl<'a, R: RawRwLock + 'a, T: ?Sized + 'a> Drop for MappedRwLockWriteGuard<'a, impl<'a, R: RawRwLock + 'a, T: fmt::Debug + ?Sized + 'a> fmt::Debug for MappedRwLockWriteGuard<'a, R, T> { - fn fmt(&self, f: &mut fmt::Formatter) -> fmt::Result { + fn fmt(&self, f: &mut fmt::Formatter<'_>) -> fmt::Result { fmt::Debug::fmt(&**self, f) } } @@ -1535,7 +1541,7 @@ impl<'a, R: RawRwLock + 'a, T: fmt::Debug + ?Sized + 'a> fmt::Debug impl<'a, R: RawRwLock + 'a, T: fmt::Display + ?Sized + 'a> fmt::Display for MappedRwLockWriteGuard<'a, R, T> { - fn fmt(&self, f: &mut fmt::Formatter) -> fmt::Result { + fn fmt(&self, f: &mut fmt::Formatter<'_>) -> fmt::Result { (**self).fmt(f) } } diff --git a/src/condvar.rs b/src/condvar.rs index cb85e885..2cf3c2bd 100644 --- a/src/condvar.rs +++ b/src/condvar.rs @@ -5,15 +5,15 @@ // http://opensource.org/licenses/MIT>, at your option. This file may not be // copied, modified, or distributed except according to those terms. -use deadlock; +use crate::deadlock; +use crate::mutex::MutexGuard; +use crate::raw_mutex::{RawMutex, TOKEN_HANDOFF, TOKEN_NORMAL}; +use crate::util; use lock_api::RawMutex as RawMutexTrait; -use mutex::MutexGuard; use parking_lot_core::{self, ParkResult, RequeueOp, UnparkResult, DEFAULT_PARK_TOKEN}; -use raw_mutex::{RawMutex, TOKEN_HANDOFF, TOKEN_NORMAL}; use std::sync::atomic::{AtomicPtr, Ordering}; use std::time::{Duration, Instant}; use std::{fmt, ptr}; -use util; /// A type indicating whether a timed wait on a condition variable returned /// due to a time out or not. @@ -263,7 +263,7 @@ impl Condvar { /// This function will panic if another thread is waiting on the `Condvar` /// with a different `Mutex` object. #[inline] - pub fn wait(&self, mutex_guard: &mut MutexGuard) { + pub fn wait(&self, mutex_guard: &mut MutexGuard<'_, T>) { self.wait_until_internal(unsafe { MutexGuard::mutex(mutex_guard).raw() }, None); } @@ -293,7 +293,7 @@ impl Condvar { #[inline] pub fn wait_until( &self, - mutex_guard: &mut MutexGuard, + mutex_guard: &mut MutexGuard<'_, T>, timeout: Instant, ) -> WaitTimeoutResult { self.wait_until_internal( @@ -397,7 +397,7 @@ impl Condvar { #[inline] pub fn wait_for( &self, - mutex_guard: &mut MutexGuard, + mutex_guard: &mut MutexGuard<'_, T>, timeout: Duration, ) -> WaitTimeoutResult { let deadline = util::to_deadline(timeout); @@ -413,18 +413,18 @@ impl Default for Condvar { } impl fmt::Debug for Condvar { - fn fmt(&self, f: &mut fmt::Formatter) -> fmt::Result { + fn fmt(&self, f: &mut fmt::Formatter<'_>) -> fmt::Result { f.pad("Condvar { .. }") } } #[cfg(test)] mod tests { + use crate::{Condvar, Mutex, MutexGuard}; use std::sync::mpsc::channel; use std::sync::Arc; use std::thread; use std::time::{Duration, Instant}; - use {Condvar, Mutex}; #[test] fn smoke() { @@ -668,7 +668,7 @@ mod tests { let mut g = m.lock(); while !c.notify_one() { // Wait for the thread to get into wait() - ::MutexGuard::bump(&mut g); + MutexGuard::bump(&mut g); } // The thread should have been requeued to the mutex, which we wake up now. drop(g); diff --git a/src/deadlock.rs b/src/deadlock.rs index 7143eb5d..810edf1f 100644 --- a/src/deadlock.rs +++ b/src/deadlock.rs @@ -40,13 +40,13 @@ pub(crate) use parking_lot_core::deadlock::{acquire_resource, release_resource}; #[cfg(test)] #[cfg(feature = "deadlock_detection")] mod tests { + use crate::{Mutex, ReentrantMutex, RwLock}; use std::sync::{Arc, Barrier}; use std::thread::{self, sleep}; use std::time::Duration; - use {Mutex, ReentrantMutex, RwLock}; // We need to serialize these tests since deadlock detection uses global state - lazy_static! { + lazy_static::lazy_static! { static ref DEADLOCK_DETECTION_LOCK: Mutex<()> = Mutex::new(()); } diff --git a/src/lib.rs b/src/lib.rs index 0edd1df1..432480aa 100644 --- a/src/lib.rs +++ b/src/lib.rs @@ -15,14 +15,6 @@ #![cfg_attr(feature = "nightly", feature(asm))] #![cfg_attr(feature = "nightly", feature(time_checked_add))] -extern crate lock_api; -extern crate parking_lot_core; - -#[cfg(test)] -#[cfg(feature = "deadlock_detection")] -#[macro_use] -extern crate lazy_static; - mod condvar; mod elision; mod mutex; @@ -38,13 +30,15 @@ pub mod deadlock; #[cfg(not(feature = "deadlock_detection"))] mod deadlock; -pub use condvar::{Condvar, WaitTimeoutResult}; -pub use mutex::{MappedMutexGuard, Mutex, MutexGuard}; -pub use once::{Once, OnceState, ONCE_INIT}; -pub use raw_mutex::RawMutex; -pub use raw_rwlock::RawRwLock; -pub use remutex::{MappedReentrantMutexGuard, RawThreadId, ReentrantMutex, ReentrantMutexGuard}; -pub use rwlock::{ +pub use self::condvar::{Condvar, WaitTimeoutResult}; +pub use self::mutex::{MappedMutexGuard, Mutex, MutexGuard}; +pub use self::once::{Once, OnceState, ONCE_INIT}; +pub use self::raw_mutex::RawMutex; +pub use self::raw_rwlock::RawRwLock; +pub use self::remutex::{ + MappedReentrantMutexGuard, RawThreadId, ReentrantMutex, ReentrantMutexGuard, +}; +pub use self::rwlock::{ MappedRwLockReadGuard, MappedRwLockWriteGuard, RwLock, RwLockReadGuard, RwLockUpgradableReadGuard, RwLockWriteGuard, }; diff --git a/src/mutex.rs b/src/mutex.rs index 0756c675..57ab2378 100644 --- a/src/mutex.rs +++ b/src/mutex.rs @@ -5,8 +5,8 @@ // http://opensource.org/licenses/MIT>, at your option. This file may not be // copied, modified, or distributed except according to those terms. +use crate::raw_mutex::RawMutex; use lock_api; -use raw_mutex::RawMutex; /// A mutual exclusion primitive useful for protecting shared data /// @@ -105,11 +105,11 @@ pub type MappedMutexGuard<'a, T> = lock_api::MappedMutexGuard<'a, RawMutex, T>; #[cfg(test)] mod tests { + use crate::{Condvar, Mutex}; use std::sync::atomic::{AtomicUsize, Ordering}; use std::sync::mpsc::channel; use std::sync::Arc; use std::thread; - use {Condvar, Mutex}; struct Packet(Arc<(Mutex, Condvar)>); diff --git a/src/once.rs b/src/once.rs index 649f4b90..440b4137 100644 --- a/src/once.rs +++ b/src/once.rs @@ -14,10 +14,10 @@ type U8 = u8; use std::sync::atomic::AtomicUsize as AtomicU8; #[cfg(not(feature = "nightly"))] type U8 = usize; +use crate::util::UncheckedOptionExt; use parking_lot_core::{self, SpinWait, DEFAULT_PARK_TOKEN, DEFAULT_UNPARK_TOKEN}; use std::fmt; use std::mem; -use util::UncheckedOptionExt; const DONE_BIT: U8 = 1; const POISON_BIT: U8 = 2; @@ -221,7 +221,7 @@ impl Once { // without some allocation overhead. #[cold] #[inline(never)] - fn call_once_slow(&self, ignore_poison: bool, f: &mut FnMut(OnceState)) { + fn call_once_slow(&self, ignore_poison: bool, f: &mut dyn FnMut(OnceState)) { let mut spinwait = SpinWait::new(); let mut state = self.0.load(Ordering::Relaxed); loop { @@ -342,7 +342,7 @@ impl Default for Once { } impl fmt::Debug for Once { - fn fmt(&self, f: &mut fmt::Formatter) -> fmt::Result { + fn fmt(&self, f: &mut fmt::Formatter<'_>) -> fmt::Result { f.debug_struct("Once") .field("state", &self.state()) .finish() @@ -351,10 +351,10 @@ impl fmt::Debug for Once { #[cfg(test)] mod tests { + use crate::{Once, ONCE_INIT}; use std::panic; use std::sync::mpsc::channel; use std::thread; - use {Once, ONCE_INIT}; #[test] fn smoke_once() { diff --git a/src/raw_mutex.rs b/src/raw_mutex.rs index b3e050ff..b5ac5ead 100644 --- a/src/raw_mutex.rs +++ b/src/raw_mutex.rs @@ -14,11 +14,11 @@ type U8 = u8; use std::sync::atomic::AtomicUsize as AtomicU8; #[cfg(not(feature = "nightly"))] type U8 = usize; -use deadlock; +use crate::deadlock; +use crate::util; use lock_api::{GuardNoSend, RawMutex as RawMutexTrait, RawMutexFair, RawMutexTimed}; use parking_lot_core::{self, ParkResult, SpinWait, UnparkResult, UnparkToken, DEFAULT_PARK_TOKEN}; use std::time::{Duration, Instant}; -use util; // UnparkToken used to indicate that that the target thread should attempt to // lock the mutex again as soon as it is unparked. diff --git a/src/raw_rwlock.rs b/src/raw_rwlock.rs index 51f5c0c9..5a9382ab 100644 --- a/src/raw_rwlock.rs +++ b/src/raw_rwlock.rs @@ -5,7 +5,9 @@ // http://opensource.org/licenses/MIT>, at your option. This file may not be // copied, modified, or distributed except according to those terms. -use elision::{have_elision, AtomicElisionExt}; +use crate::elision::{have_elision, AtomicElisionExt}; +use crate::raw_mutex::{TOKEN_HANDOFF, TOKEN_NORMAL}; +use crate::util; use lock_api::{ GuardNoSend, RawRwLock as RawRwLockTrait, RawRwLockDowngrade, RawRwLockFair, RawRwLockRecursive, RawRwLockRecursiveTimed, RawRwLockTimed, RawRwLockUpgrade, @@ -14,11 +16,9 @@ use lock_api::{ use parking_lot_core::{ self, deadlock, FilterOp, ParkResult, ParkToken, SpinWait, UnparkResult, UnparkToken, }; -use raw_mutex::{TOKEN_HANDOFF, TOKEN_NORMAL}; use std::cell::Cell; use std::sync::atomic::{AtomicUsize, Ordering}; use std::time::{Duration, Instant}; -use util; // This reader-writer lock implementation is based on Boost's upgrade_mutex: // https://github.com/boostorg/thread/blob/fc08c1fe2840baeeee143440fba31ef9e9a813c8/include/boost/thread/v2/shared_mutex.hpp#L432 diff --git a/src/remutex.rs b/src/remutex.rs index aa40e144..db06ee8b 100644 --- a/src/remutex.rs +++ b/src/remutex.rs @@ -5,8 +5,8 @@ // http://opensource.org/licenses/MIT>, at your option. This file may not be // copied, modified, or distributed except according to those terms. +use crate::raw_mutex::RawMutex; use lock_api::{self, GetThreadId}; -use raw_mutex::RawMutex; /// Implementation of the `GetThreadId` trait for `lock_api::ReentrantMutex`. pub struct RawThreadId; @@ -54,10 +54,10 @@ pub type MappedReentrantMutexGuard<'a, T> = #[cfg(test)] mod tests { + use crate::ReentrantMutex; use std::cell::RefCell; use std::sync::Arc; use std::thread; - use ReentrantMutex; #[test] fn smoke() { diff --git a/src/rwlock.rs b/src/rwlock.rs index 63ef4271..03abe8b7 100644 --- a/src/rwlock.rs +++ b/src/rwlock.rs @@ -5,8 +5,8 @@ // http://opensource.org/licenses/MIT>, at your option. This file may not be // copied, modified, or distributed except according to those terms. +use crate::raw_rwlock::RawRwLock; use lock_api; -use raw_rwlock::RawRwLock; /// A reader-writer lock /// @@ -120,14 +120,13 @@ pub type RwLockUpgradableReadGuard<'a, T> = lock_api::RwLockUpgradableReadGuard< #[cfg(test)] mod tests { - extern crate rand; - use self::rand::Rng; + use crate::{RwLock, RwLockUpgradableReadGuard, RwLockWriteGuard}; + use rand::Rng; use std::sync::atomic::{AtomicUsize, Ordering}; use std::sync::mpsc::channel; use std::sync::Arc; use std::thread; use std::time::Duration; - use {RwLock, RwLockUpgradableReadGuard, RwLockWriteGuard}; #[derive(Eq, PartialEq, Debug)] struct NonCopy(i32); From c45d4e9cbe65f27fa8a7940ef00d7b5b077c5fb6 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Linus=20F=C3=A4rnstrand?= Date: Mon, 4 Mar 2019 18:32:36 +0100 Subject: [PATCH 5/9] Cleanup/restructure use statements --- core/src/parking_lot.rs | 11 ++++--- core/src/thread_parker/generic.rs | 5 ++- core/src/thread_parker/linux.rs | 9 +++--- core/src/thread_parker/unix.rs | 16 ++++++---- core/src/thread_parker/windows/keyed_event.rs | 32 ++++++++++++------- core/src/thread_parker/windows/mod.rs | 6 ++-- core/src/thread_parker/windows/waitaddress.rs | 27 ++++++++++------ core/src/word_lock.rs | 9 +++--- src/condvar.rs | 9 +++--- src/once.rs | 3 +- src/raw_mutex.rs | 6 ++-- src/raw_rwlock.rs | 6 ++-- 12 files changed, 82 insertions(+), 57 deletions(-) diff --git a/core/src/parking_lot.rs b/core/src/parking_lot.rs index 791da994..d461fbdf 100644 --- a/core/src/parking_lot.rs +++ b/core/src/parking_lot.rs @@ -8,12 +8,13 @@ use crate::thread_parker::ThreadParker; use crate::util::UncheckedOptionExt; use crate::word_lock::WordLock; -use rand::rngs::SmallRng; -use rand::{FromEntropy, Rng}; +use core::{ + cell::{Cell, UnsafeCell}, + ptr, + sync::atomic::{AtomicPtr, AtomicUsize, Ordering}, +}; +use rand::{rngs::SmallRng, FromEntropy, Rng}; use smallvec::SmallVec; -use std::cell::{Cell, UnsafeCell}; -use std::ptr; -use std::sync::atomic::{AtomicPtr, AtomicUsize, Ordering}; use std::time::{Duration, Instant}; static NUM_THREADS: AtomicUsize = AtomicUsize::new(0); diff --git a/core/src/thread_parker/generic.rs b/core/src/thread_parker/generic.rs index eedf733e..bcfc86df 100644 --- a/core/src/thread_parker/generic.rs +++ b/core/src/thread_parker/generic.rs @@ -8,9 +8,8 @@ //! A simple spin lock based thread parker. Used on platforms without better //! parking facilities available. -use std::sync::atomic::{spin_loop_hint, AtomicBool, Ordering}; -use std::thread; -use std::time::Instant; +use core::sync::atomic::{spin_loop_hint, AtomicBool, Ordering}; +use std::{thread, time::Instant}; // Helper type for putting a thread to sleep until some other thread wakes it up pub struct ThreadParker { diff --git a/core/src/thread_parker/linux.rs b/core/src/thread_parker/linux.rs index 040301a3..319d04ea 100644 --- a/core/src/thread_parker/linux.rs +++ b/core/src/thread_parker/linux.rs @@ -5,11 +5,12 @@ // http://opensource.org/licenses/MIT>, at your option. This file may not be // copied, modified, or distributed except according to those terms. +use core::{ + ptr, + sync::atomic::{AtomicI32, Ordering}, +}; use libc; -use std::ptr; -use std::sync::atomic::{AtomicI32, Ordering}; -use std::thread; -use std::time::Instant; +use std::{thread, time::Instant}; const FUTEX_WAIT: i32 = 0; const FUTEX_WAKE: i32 = 1; diff --git a/core/src/thread_parker/unix.rs b/core/src/thread_parker/unix.rs index 1b21d1f9..8712ebdf 100644 --- a/core/src/thread_parker/unix.rs +++ b/core/src/thread_parker/unix.rs @@ -5,13 +5,17 @@ // http://opensource.org/licenses/MIT>, at your option. This file may not be // copied, modified, or distributed except according to those terms. -use libc; -use std::cell::{Cell, UnsafeCell}; -use std::mem; #[cfg(any(target_os = "macos", target_os = "ios"))] -use std::ptr; -use std::thread; -use std::time::{Duration, Instant}; +use core::ptr; +use core::{ + cell::{Cell, UnsafeCell}, + mem, +}; +use libc; +use std::{ + thread, + time::{Duration, Instant}, +}; // x32 Linux uses a non-standard type for tv_nsec in timespec. // See https://sourceware.org/bugzilla/show_bug.cgi?id=16437 diff --git a/core/src/thread_parker/windows/keyed_event.rs b/core/src/thread_parker/windows/keyed_event.rs index bb8bcb11..71b55f0f 100644 --- a/core/src/thread_parker/windows/keyed_event.rs +++ b/core/src/thread_parker/windows/keyed_event.rs @@ -5,18 +5,26 @@ // http://opensource.org/licenses/MIT>, at your option. This file may not be // copied, modified, or distributed except according to those terms. -use std::mem; -use std::ptr; -use std::sync::atomic::{AtomicUsize, Ordering}; -use std::time::Instant; - -use winapi::shared::minwindef::{TRUE, ULONG}; -use winapi::shared::ntdef::NTSTATUS; -use winapi::shared::ntstatus::{STATUS_SUCCESS, STATUS_TIMEOUT}; -use winapi::um::handleapi::CloseHandle; -use winapi::um::libloaderapi::{GetModuleHandleA, GetProcAddress}; -use winapi::um::winnt::{ACCESS_MASK, GENERIC_READ, GENERIC_WRITE, LPCSTR}; -use winapi::um::winnt::{BOOLEAN, HANDLE, LARGE_INTEGER, PHANDLE, PLARGE_INTEGER, PVOID}; +use core::{mem, ptr}; +use std::{ + sync::atomic::{AtomicUsize, Ordering}, + time::Instant, +}; +use winapi::{ + shared::{ + minwindef::{TRUE, ULONG}, + ntdef::NTSTATUS, + ntstatus::{STATUS_SUCCESS, STATUS_TIMEOUT}, + }, + um::{ + handleapi::CloseHandle, + libloaderapi::{GetModuleHandleA, GetProcAddress}, + winnt::{ + ACCESS_MASK, BOOLEAN, GENERIC_READ, GENERIC_WRITE, HANDLE, LARGE_INTEGER, LPCSTR, + PHANDLE, PLARGE_INTEGER, PVOID, + }, + }, +}; const STATE_UNPARKED: usize = 0; const STATE_PARKED: usize = 1; diff --git a/core/src/thread_parker/windows/mod.rs b/core/src/thread_parker/windows/mod.rs index 7e17dec2..32f51c2d 100644 --- a/core/src/thread_parker/windows/mod.rs +++ b/core/src/thread_parker/windows/mod.rs @@ -5,8 +5,10 @@ // http://opensource.org/licenses/MIT>, at your option. This file may not be // copied, modified, or distributed except according to those terms. -use std::ptr; -use std::sync::atomic::{AtomicPtr, AtomicUsize, Ordering}; +use core::{ + ptr, + sync::atomic::{AtomicPtr, AtomicUsize, Ordering}, +}; use std::time::Instant; mod keyed_event; diff --git a/core/src/thread_parker/windows/waitaddress.rs b/core/src/thread_parker/windows/waitaddress.rs index cd449c5c..0ec78040 100644 --- a/core/src/thread_parker/windows/waitaddress.rs +++ b/core/src/thread_parker/windows/waitaddress.rs @@ -5,17 +5,24 @@ // http://opensource.org/licenses/MIT>, at your option. This file may not be // copied, modified, or distributed except according to those terms. -use std::mem; -use std::sync::atomic::{AtomicUsize, Ordering}; +use core::{ + mem, + sync::atomic::{AtomicUsize, Ordering}, +}; use std::time::Instant; - -use winapi::shared::basetsd::SIZE_T; -use winapi::shared::minwindef::{BOOL, DWORD, FALSE, TRUE}; -use winapi::shared::winerror::ERROR_TIMEOUT; -use winapi::um::errhandlingapi::GetLastError; -use winapi::um::libloaderapi::{GetModuleHandleA, GetProcAddress}; -use winapi::um::winbase::INFINITE; -use winapi::um::winnt::{LPCSTR, PVOID}; +use winapi::{ + shared::{ + basetsd::SIZE_T, + minwindef::{BOOL, DWORD, FALSE, TRUE}, + winerror::ERROR_TIMEOUT, + }, + um::{ + errhandlingapi::GetLastError, + libloaderapi::{GetModuleHandleA, GetProcAddress}, + winbase::INFINITE, + winnt::{LPCSTR, PVOID}, + }, +}; #[allow(non_snake_case)] pub struct WaitAddress { diff --git a/core/src/word_lock.rs b/core/src/word_lock.rs index 054144e9..a6a10e83 100644 --- a/core/src/word_lock.rs +++ b/core/src/word_lock.rs @@ -7,10 +7,11 @@ use crate::spinwait::SpinWait; use crate::thread_parker::ThreadParker; -use std::cell::Cell; -use std::mem; -use std::ptr; -use std::sync::atomic::{fence, AtomicUsize, Ordering}; +use core::{ + cell::Cell, + mem, ptr, + sync::atomic::{fence, AtomicUsize, Ordering}, +}; struct ThreadData { parker: ThreadParker, diff --git a/src/condvar.rs b/src/condvar.rs index 2cf3c2bd..5e772d35 100644 --- a/src/condvar.rs +++ b/src/condvar.rs @@ -5,15 +5,16 @@ // http://opensource.org/licenses/MIT>, at your option. This file may not be // copied, modified, or distributed except according to those terms. -use crate::deadlock; use crate::mutex::MutexGuard; use crate::raw_mutex::{RawMutex, TOKEN_HANDOFF, TOKEN_NORMAL}; -use crate::util; +use crate::{deadlock, util}; +use core::{ + fmt, ptr, + sync::atomic::{AtomicPtr, Ordering}, +}; use lock_api::RawMutex as RawMutexTrait; use parking_lot_core::{self, ParkResult, RequeueOp, UnparkResult, DEFAULT_PARK_TOKEN}; -use std::sync::atomic::{AtomicPtr, Ordering}; use std::time::{Duration, Instant}; -use std::{fmt, ptr}; /// A type indicating whether a timed wait on a condition variable returned /// due to a time out or not. diff --git a/src/once.rs b/src/once.rs index 440b4137..628c0577 100644 --- a/src/once.rs +++ b/src/once.rs @@ -15,9 +15,8 @@ use std::sync::atomic::AtomicUsize as AtomicU8; #[cfg(not(feature = "nightly"))] type U8 = usize; use crate::util::UncheckedOptionExt; +use core::{fmt, mem}; use parking_lot_core::{self, SpinWait, DEFAULT_PARK_TOKEN, DEFAULT_UNPARK_TOKEN}; -use std::fmt; -use std::mem; const DONE_BIT: U8 = 1; const POISON_BIT: U8 = 2; diff --git a/src/raw_mutex.rs b/src/raw_mutex.rs index b5ac5ead..86c29a9d 100644 --- a/src/raw_mutex.rs +++ b/src/raw_mutex.rs @@ -6,12 +6,12 @@ // copied, modified, or distributed except according to those terms. #[cfg(feature = "nightly")] -use std::sync::atomic::AtomicU8; -use std::sync::atomic::Ordering; +use core::sync::atomic::AtomicU8; +use core::sync::atomic::Ordering; #[cfg(feature = "nightly")] type U8 = u8; #[cfg(not(feature = "nightly"))] -use std::sync::atomic::AtomicUsize as AtomicU8; +use core::sync::atomic::AtomicUsize as AtomicU8; #[cfg(not(feature = "nightly"))] type U8 = usize; use crate::deadlock; diff --git a/src/raw_rwlock.rs b/src/raw_rwlock.rs index 5a9382ab..ccfe4616 100644 --- a/src/raw_rwlock.rs +++ b/src/raw_rwlock.rs @@ -8,6 +8,10 @@ use crate::elision::{have_elision, AtomicElisionExt}; use crate::raw_mutex::{TOKEN_HANDOFF, TOKEN_NORMAL}; use crate::util; +use core::{ + cell::Cell, + sync::atomic::{AtomicUsize, Ordering}, +}; use lock_api::{ GuardNoSend, RawRwLock as RawRwLockTrait, RawRwLockDowngrade, RawRwLockFair, RawRwLockRecursive, RawRwLockRecursiveTimed, RawRwLockTimed, RawRwLockUpgrade, @@ -16,8 +20,6 @@ use lock_api::{ use parking_lot_core::{ self, deadlock, FilterOp, ParkResult, ParkToken, SpinWait, UnparkResult, UnparkToken, }; -use std::cell::Cell; -use std::sync::atomic::{AtomicUsize, Ordering}; use std::time::{Duration, Instant}; // This reader-writer lock implementation is based on Boost's upgrade_mutex: From 69a3511ee2eebad706e763d05868c562c1c24a7f Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Linus=20F=C3=A4rnstrand?= Date: Mon, 4 Mar 2019 18:03:03 +0100 Subject: [PATCH 6/9] Bump min required version to 1.31 --- .travis.yml | 3 +-- README.md | 2 +- appveyor.yml | 8 ++++---- 3 files changed, 6 insertions(+), 7 deletions(-) diff --git a/.travis.yml b/.travis.yml index 8ea2d8c2..d8fa9cec 100644 --- a/.travis.yml +++ b/.travis.yml @@ -2,8 +2,7 @@ language: rust sudo: false rust: -- 1.24.0 -- 1.26.2 +- 1.31.0 - stable - beta - nightly diff --git a/README.md b/README.md index a8f339ae..b3b94be5 100644 --- a/README.md +++ b/README.md @@ -124,7 +124,7 @@ changes to the core API do not cause breaking changes for users of `parking_lot` ## Minimum Rust version -The current minimum required Rust version is 1.24. Any change to this is +The current minimum required Rust version is 1.31. Any change to this is considered a breaking change and will require a major version bump. ## License diff --git a/appveyor.yml b/appveyor.yml index 83498db3..8a084a86 100644 --- a/appveyor.yml +++ b/appveyor.yml @@ -6,10 +6,10 @@ environment: - TARGET: nightly-i686-pc-windows-msvc - TARGET: nightly-x86_64-pc-windows-gnu - TARGET: nightly-i686-pc-windows-gnu - - TARGET: 1.24.0-x86_64-pc-windows-msvc - - TARGET: 1.24.0-i686-pc-windows-msvc - - TARGET: 1.24.0-x86_64-pc-windows-gnu - - TARGET: 1.24.0-i686-pc-windows-gnu + - TARGET: 1.31.0-x86_64-pc-windows-msvc + - TARGET: 1.31.0-i686-pc-windows-msvc + - TARGET: 1.31.0-x86_64-pc-windows-gnu + - TARGET: 1.31.0-i686-pc-windows-gnu install: - SET PATH=C:\Python27;C:\Python27\Scripts;%PATH%;%APPDATA%\Python\Scripts From db7f7f94379ceb73fa730cbbce76d695c62c269b Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Linus=20F=C3=A4rnstrand?= Date: Mon, 4 Mar 2019 18:05:34 +0100 Subject: [PATCH 7/9] Bump versions --- Cargo.toml | 6 +++--- README.md | 4 ++-- core/Cargo.toml | 2 +- lock_api/Cargo.toml | 2 +- 4 files changed, 7 insertions(+), 7 deletions(-) diff --git a/Cargo.toml b/Cargo.toml index 1cce9475..4094d964 100644 --- a/Cargo.toml +++ b/Cargo.toml @@ -1,6 +1,6 @@ [package] name = "parking_lot" -version = "0.7.1" +version = "0.8.0" authors = ["Amanieu d'Antras "] description = "More compact and efficient implementations of the standard synchronization primitives." license = "Apache-2.0/MIT" @@ -11,8 +11,8 @@ categories = ["concurrency"] edition = "2018" [dependencies] -parking_lot_core = { path = "core", version = "0.4" } -lock_api = { path = "lock_api", version = "0.1" } +parking_lot_core = { path = "core", version = "0.5" } +lock_api = { path = "lock_api", version = "0.2" } [dev-dependencies] rand = "0.6" diff --git a/README.md b/README.md index b3b94be5..460d0057 100644 --- a/README.md +++ b/README.md @@ -99,7 +99,7 @@ Add this to your `Cargo.toml`: ```toml [dependencies] -parking_lot = "0.6" +parking_lot = "0.8" ``` and this to your crate root: @@ -112,7 +112,7 @@ To enable nightly-only features, add this to your `Cargo.toml` instead: ```toml [dependencies] -parking_lot = {version = "0.6", features = ["nightly"]} +parking_lot = {version = "0.8", features = ["nightly"]} ``` The experimental deadlock detector can be enabled with the diff --git a/core/Cargo.toml b/core/Cargo.toml index 90c95da4..c4027dd9 100644 --- a/core/Cargo.toml +++ b/core/Cargo.toml @@ -1,6 +1,6 @@ [package] name = "parking_lot_core" -version = "0.4.0" +version = "0.5.0" authors = ["Amanieu d'Antras "] description = "An advanced API for creating custom synchronization primitives." license = "Apache-2.0/MIT" diff --git a/lock_api/Cargo.toml b/lock_api/Cargo.toml index 75b767aa..65d6d4f7 100644 --- a/lock_api/Cargo.toml +++ b/lock_api/Cargo.toml @@ -1,6 +1,6 @@ [package] name = "lock_api" -version = "0.1.5" +version = "0.2.0" authors = ["Amanieu d'Antras "] description = "Wrappers to create fully-featured Mutex and RwLock types. Compatible with no_std." license = "Apache-2.0/MIT" From a976430372a32b560888fa533549fb9614ba871a Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Linus=20F=C3=A4rnstrand?= Date: Mon, 4 Mar 2019 19:15:04 +0100 Subject: [PATCH 8/9] Enable 2018 edition idiom warnings --- core/src/lib.rs | 1 + lock_api/src/lib.rs | 1 + src/lib.rs | 1 + 3 files changed, 3 insertions(+) diff --git a/core/src/lib.rs b/core/src/lib.rs index 3ae0ab41..7188d795 100644 --- a/core/src/lib.rs +++ b/core/src/lib.rs @@ -38,6 +38,7 @@ //! reference count and the two mutex bits in the same atomic word. #![warn(missing_docs)] +#![warn(rust_2018_idioms)] #![cfg_attr( all(feature = "nightly", target_os = "linux"), feature(integer_atomics) diff --git a/lock_api/src/lib.rs b/lock_api/src/lib.rs index 0eb8a563..d388d8a3 100644 --- a/lock_api/src/lib.rs +++ b/lock_api/src/lib.rs @@ -85,6 +85,7 @@ #![no_std] #![warn(missing_docs)] +#![warn(rust_2018_idioms)] #![cfg_attr(feature = "nightly", feature(const_fn))] #[macro_use] diff --git a/src/lib.rs b/src/lib.rs index 432480aa..7a8f999f 100644 --- a/src/lib.rs +++ b/src/lib.rs @@ -10,6 +10,7 @@ //! standard library. It also provides a `ReentrantMutex` type. #![warn(missing_docs)] +#![warn(rust_2018_idioms)] #![cfg_attr(feature = "nightly", feature(const_fn))] #![cfg_attr(feature = "nightly", feature(integer_atomics))] #![cfg_attr(feature = "nightly", feature(asm))] From d88854de71cf6f19138b227c4650bec6073a2bae Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Linus=20F=C3=A4rnstrand?= Date: Mon, 4 Mar 2019 22:31:15 +0100 Subject: [PATCH 9/9] Remove stabilized attributes --- core/src/lib.rs | 4 ---- src/lib.rs | 3 --- 2 files changed, 7 deletions(-) diff --git a/core/src/lib.rs b/core/src/lib.rs index 7188d795..d01846dd 100644 --- a/core/src/lib.rs +++ b/core/src/lib.rs @@ -39,10 +39,6 @@ #![warn(missing_docs)] #![warn(rust_2018_idioms)] -#![cfg_attr( - all(feature = "nightly", target_os = "linux"), - feature(integer_atomics) -)] #[cfg(all(feature = "nightly", target_os = "linux"))] #[path = "thread_parker/linux.rs"] diff --git a/src/lib.rs b/src/lib.rs index 7a8f999f..f4c7a493 100644 --- a/src/lib.rs +++ b/src/lib.rs @@ -11,10 +11,7 @@ #![warn(missing_docs)] #![warn(rust_2018_idioms)] -#![cfg_attr(feature = "nightly", feature(const_fn))] -#![cfg_attr(feature = "nightly", feature(integer_atomics))] #![cfg_attr(feature = "nightly", feature(asm))] -#![cfg_attr(feature = "nightly", feature(time_checked_add))] mod condvar; mod elision;