about summary refs log tree commit diff
path: root/library/std/src/sync
diff options
context:
space:
mode:
authorNicholas Nethercote <n.nethercote@gmail.com>2024-07-29 08:13:50 +1000
committerNicholas Nethercote <n.nethercote@gmail.com>2024-07-29 08:26:52 +1000
commit84ac80f1921afc243d71fd0caaa4f2838c294102 (patch)
tree29006db815bf547dfd0129910b23b8c54675bd98 /library/std/src/sync
parent118f9350c5b902e462a6dcc4325670f3da701600 (diff)
Reformat `use` declarations.
The previous commit updated `rustfmt.toml` appropriately. This commit is
the outcome of running `x fmt --all` with the new formatting options.
Diffstat (limited to 'library/std/src/sync')
-rw-r--r--library/std/src/sync/lazy_lock.rs3
-rw-r--r--library/std/src/sync/lazy_lock/tests.rs15
-rw-r--r--library/std/src/sync/mod.rs19
-rw-r--r--library/std/src/sync/mpmc/array.rs1
-rw-r--r--library/std/src/sync/mpmc/context.rs1
-rw-r--r--library/std/src/sync/mpmc/counter.rs3
-rw-r--r--library/std/src/sync/mpmc/error.rs4
-rw-r--r--library/std/src/sync/mpmc/list.rs1
-rw-r--r--library/std/src/sync/mpmc/mod.rs3
-rw-r--r--library/std/src/sync/mpmc/waker.rs1
-rw-r--r--library/std/src/sync/mpmc/zero.rs1
-rw-r--r--library/std/src/sync/mpsc/mod.rs3
-rw-r--r--library/std/src/sync/mpsc/sync_tests.rs3
-rw-r--r--library/std/src/sync/mpsc/tests.rs3
-rw-r--r--library/std/src/sync/once/tests.rs3
-rw-r--r--library/std/src/sync/once_lock/tests.rs14
-rw-r--r--library/std/src/sync/poison.rs1
-rw-r--r--library/std/src/sync/rwlock/tests.rs3
18 files changed, 30 insertions, 52 deletions
diff --git a/library/std/src/sync/lazy_lock.rs b/library/std/src/sync/lazy_lock.rs
index 9fe9ccab4a9..953aef40e7b 100644
--- a/library/std/src/sync/lazy_lock.rs
+++ b/library/std/src/sync/lazy_lock.rs
@@ -1,3 +1,4 @@
+use super::once::ExclusiveState;
 use crate::cell::UnsafeCell;
 use crate::mem::ManuallyDrop;
 use crate::ops::Deref;
@@ -5,8 +6,6 @@ use crate::panic::{RefUnwindSafe, UnwindSafe};
 use crate::sync::Once;
 use crate::{fmt, ptr};
 
-use super::once::ExclusiveState;
-
 // We use the state of a Once as discriminant value. Upon creation, the state is
 // "incomplete" and `f` contains the initialization closure. In the first call to
 // `call_once`, `f` is taken and run. If it succeeds, `value` is set and the state
diff --git a/library/std/src/sync/lazy_lock/tests.rs b/library/std/src/sync/lazy_lock/tests.rs
index a5d4e25c596..8a6ab4ac4fd 100644
--- a/library/std/src/sync/lazy_lock/tests.rs
+++ b/library/std/src/sync/lazy_lock/tests.rs
@@ -1,13 +1,8 @@
-use crate::{
-    cell::LazyCell,
-    panic,
-    sync::{
-        atomic::{AtomicUsize, Ordering::SeqCst},
-        Mutex,
-    },
-    sync::{LazyLock, OnceLock},
-    thread,
-};
+use crate::cell::LazyCell;
+use crate::sync::atomic::AtomicUsize;
+use crate::sync::atomic::Ordering::SeqCst;
+use crate::sync::{LazyLock, Mutex, OnceLock};
+use crate::{panic, thread};
 
 fn spawn_and_wait<R: Send + 'static>(f: impl FnOnce() -> R + Send + 'static) -> R {
     thread::spawn(f).join().unwrap()
diff --git a/library/std/src/sync/mod.rs b/library/std/src/sync/mod.rs
index 9a38c42f43a..d0ba8cc3b47 100644
--- a/library/std/src/sync/mod.rs
+++ b/library/std/src/sync/mod.rs
@@ -159,16 +159,19 @@
 #![stable(feature = "rust1", since = "1.0.0")]
 
 #[stable(feature = "rust1", since = "1.0.0")]
-pub use alloc_crate::sync::{Arc, Weak};
-#[stable(feature = "rust1", since = "1.0.0")]
 pub use core::sync::atomic;
 #[unstable(feature = "exclusive_wrapper", issue = "98407")]
 pub use core::sync::Exclusive;
 
 #[stable(feature = "rust1", since = "1.0.0")]
+pub use alloc_crate::sync::{Arc, Weak};
+
+#[stable(feature = "rust1", since = "1.0.0")]
 pub use self::barrier::{Barrier, BarrierWaitResult};
 #[stable(feature = "rust1", since = "1.0.0")]
 pub use self::condvar::{Condvar, WaitTimeoutResult};
+#[stable(feature = "lazy_cell", since = "1.80.0")]
+pub use self::lazy_lock::LazyLock;
 #[unstable(feature = "mapped_lock_guards", issue = "117108")]
 pub use self::mutex::MappedMutexGuard;
 #[stable(feature = "rust1", since = "1.0.0")]
@@ -176,21 +179,17 @@ pub use self::mutex::{Mutex, MutexGuard};
 #[stable(feature = "rust1", since = "1.0.0")]
 #[allow(deprecated)]
 pub use self::once::{Once, OnceState, ONCE_INIT};
+#[stable(feature = "once_cell", since = "1.70.0")]
+pub use self::once_lock::OnceLock;
 #[stable(feature = "rust1", since = "1.0.0")]
 pub use self::poison::{LockResult, PoisonError, TryLockError, TryLockResult};
+#[unstable(feature = "reentrant_lock", issue = "121440")]
+pub use self::reentrant_lock::{ReentrantLock, ReentrantLockGuard};
 #[unstable(feature = "mapped_lock_guards", issue = "117108")]
 pub use self::rwlock::{MappedRwLockReadGuard, MappedRwLockWriteGuard};
 #[stable(feature = "rust1", since = "1.0.0")]
 pub use self::rwlock::{RwLock, RwLockReadGuard, RwLockWriteGuard};
 
-#[stable(feature = "lazy_cell", since = "1.80.0")]
-pub use self::lazy_lock::LazyLock;
-#[stable(feature = "once_cell", since = "1.70.0")]
-pub use self::once_lock::OnceLock;
-
-#[unstable(feature = "reentrant_lock", issue = "121440")]
-pub use self::reentrant_lock::{ReentrantLock, ReentrantLockGuard};
-
 pub mod mpsc;
 
 mod barrier;
diff --git a/library/std/src/sync/mpmc/array.rs b/library/std/src/sync/mpmc/array.rs
index 185319add74..34acd9c9a94 100644
--- a/library/std/src/sync/mpmc/array.rs
+++ b/library/std/src/sync/mpmc/array.rs
@@ -13,7 +13,6 @@ use super::error::*;
 use super::select::{Operation, Selected, Token};
 use super::utils::{Backoff, CachePadded};
 use super::waker::SyncWaker;
-
 use crate::cell::UnsafeCell;
 use crate::mem::MaybeUninit;
 use crate::ptr;
diff --git a/library/std/src/sync/mpmc/context.rs b/library/std/src/sync/mpmc/context.rs
index bbfc6ce00ff..8db3c9896eb 100644
--- a/library/std/src/sync/mpmc/context.rs
+++ b/library/std/src/sync/mpmc/context.rs
@@ -2,7 +2,6 @@
 
 use super::select::Selected;
 use super::waker::current_thread_id;
-
 use crate::cell::Cell;
 use crate::ptr;
 use crate::sync::atomic::{AtomicPtr, AtomicUsize, Ordering};
diff --git a/library/std/src/sync/mpmc/counter.rs b/library/std/src/sync/mpmc/counter.rs
index 3478cf41dc9..d1bfe612f53 100644
--- a/library/std/src/sync/mpmc/counter.rs
+++ b/library/std/src/sync/mpmc/counter.rs
@@ -1,6 +1,5 @@
-use crate::ops;
-use crate::process;
 use crate::sync::atomic::{AtomicBool, AtomicUsize, Ordering};
+use crate::{ops, process};
 
 /// Reference counter internals.
 struct Counter<C> {
diff --git a/library/std/src/sync/mpmc/error.rs b/library/std/src/sync/mpmc/error.rs
index 33b2bff8534..e3aec7e7623 100644
--- a/library/std/src/sync/mpmc/error.rs
+++ b/library/std/src/sync/mpmc/error.rs
@@ -1,7 +1,5 @@
-use crate::error;
-use crate::fmt;
-
 pub use crate::sync::mpsc::{RecvError, RecvTimeoutError, SendError, TryRecvError, TrySendError};
+use crate::{error, fmt};
 
 /// An error returned from the [`send_timeout`] method.
 ///
diff --git a/library/std/src/sync/mpmc/list.rs b/library/std/src/sync/mpmc/list.rs
index edac7a0cb18..bbe205cad04 100644
--- a/library/std/src/sync/mpmc/list.rs
+++ b/library/std/src/sync/mpmc/list.rs
@@ -5,7 +5,6 @@ use super::error::*;
 use super::select::{Operation, Selected, Token};
 use super::utils::{Backoff, CachePadded};
 use super::waker::SyncWaker;
-
 use crate::cell::UnsafeCell;
 use crate::marker::PhantomData;
 use crate::mem::MaybeUninit;
diff --git a/library/std/src/sync/mpmc/mod.rs b/library/std/src/sync/mpmc/mod.rs
index 2068dda393a..c640e07348e 100644
--- a/library/std/src/sync/mpmc/mod.rs
+++ b/library/std/src/sync/mpmc/mod.rs
@@ -40,10 +40,11 @@ mod utils;
 mod waker;
 mod zero;
 
+pub use error::*;
+
 use crate::fmt;
 use crate::panic::{RefUnwindSafe, UnwindSafe};
 use crate::time::{Duration, Instant};
-pub use error::*;
 
 /// Creates a channel of unbounded capacity.
 ///
diff --git a/library/std/src/sync/mpmc/waker.rs b/library/std/src/sync/mpmc/waker.rs
index 9aab1b9417e..fb877887f9c 100644
--- a/library/std/src/sync/mpmc/waker.rs
+++ b/library/std/src/sync/mpmc/waker.rs
@@ -2,7 +2,6 @@
 
 use super::context::Context;
 use super::select::{Operation, Selected};
-
 use crate::ptr;
 use crate::sync::atomic::{AtomicBool, Ordering};
 use crate::sync::Mutex;
diff --git a/library/std/src/sync/mpmc/zero.rs b/library/std/src/sync/mpmc/zero.rs
index 6d1c9d64e7a..2b82eeda3d5 100644
--- a/library/std/src/sync/mpmc/zero.rs
+++ b/library/std/src/sync/mpmc/zero.rs
@@ -7,7 +7,6 @@ use super::error::*;
 use super::select::{Operation, Selected, Token};
 use super::utils::Backoff;
 use super::waker::Waker;
-
 use crate::cell::UnsafeCell;
 use crate::marker::PhantomData;
 use crate::sync::atomic::{AtomicBool, Ordering};
diff --git a/library/std/src/sync/mpsc/mod.rs b/library/std/src/sync/mpsc/mod.rs
index feee6948db4..26d5b9515a2 100644
--- a/library/std/src/sync/mpsc/mod.rs
+++ b/library/std/src/sync/mpsc/mod.rs
@@ -148,10 +148,9 @@ mod sync_tests;
 // not exposed publicly, but if you are curious about the implementation,
 // that's where everything is.
 
-use crate::error;
-use crate::fmt;
 use crate::sync::mpmc;
 use crate::time::{Duration, Instant};
+use crate::{error, fmt};
 
 /// The receiving half of Rust's [`channel`] (or [`sync_channel`]) type.
 /// This half can only be owned by one thread.
diff --git a/library/std/src/sync/mpsc/sync_tests.rs b/library/std/src/sync/mpsc/sync_tests.rs
index 945de280f40..49b65c8efe6 100644
--- a/library/std/src/sync/mpsc/sync_tests.rs
+++ b/library/std/src/sync/mpsc/sync_tests.rs
@@ -1,8 +1,7 @@
 use super::*;
-use crate::env;
 use crate::rc::Rc;
 use crate::sync::mpmc::SendTimeoutError;
-use crate::thread;
+use crate::{env, thread};
 
 pub fn stress_factor() -> usize {
     match env::var("RUST_TEST_STRESS") {
diff --git a/library/std/src/sync/mpsc/tests.rs b/library/std/src/sync/mpsc/tests.rs
index ac1a804cf9c..13892fa0d18 100644
--- a/library/std/src/sync/mpsc/tests.rs
+++ b/library/std/src/sync/mpsc/tests.rs
@@ -1,6 +1,5 @@
 use super::*;
-use crate::env;
-use crate::thread;
+use crate::{env, thread};
 
 pub fn stress_factor() -> usize {
     match env::var("RUST_TEST_STRESS") {
diff --git a/library/std/src/sync/once/tests.rs b/library/std/src/sync/once/tests.rs
index 0c35597e11c..d43dabc1cf1 100644
--- a/library/std/src/sync/once/tests.rs
+++ b/library/std/src/sync/once/tests.rs
@@ -1,7 +1,6 @@
 use super::Once;
-use crate::panic;
 use crate::sync::mpsc::channel;
-use crate::thread;
+use crate::{panic, thread};
 
 #[test]
 fn smoke_once() {
diff --git a/library/std/src/sync/once_lock/tests.rs b/library/std/src/sync/once_lock/tests.rs
index d5d32e73d88..176830c6748 100644
--- a/library/std/src/sync/once_lock/tests.rs
+++ b/library/std/src/sync/once_lock/tests.rs
@@ -1,12 +1,8 @@
-use crate::{
-    panic,
-    sync::OnceLock,
-    sync::{
-        atomic::{AtomicUsize, Ordering::SeqCst},
-        mpsc::channel,
-    },
-    thread,
-};
+use crate::sync::atomic::AtomicUsize;
+use crate::sync::atomic::Ordering::SeqCst;
+use crate::sync::mpsc::channel;
+use crate::sync::OnceLock;
+use crate::{panic, thread};
 
 fn spawn_and_wait<R: Send + 'static>(f: impl FnOnce() -> R + Send + 'static) -> R {
     thread::spawn(f).join().unwrap()
diff --git a/library/std/src/sync/poison.rs b/library/std/src/sync/poison.rs
index d71643b5000..da66a088e51 100644
--- a/library/std/src/sync/poison.rs
+++ b/library/std/src/sync/poison.rs
@@ -1,6 +1,5 @@
 use crate::error::Error;
 use crate::fmt;
-
 #[cfg(panic = "unwind")]
 use crate::sync::atomic::{AtomicBool, Ordering};
 #[cfg(panic = "unwind")]
diff --git a/library/std/src/sync/rwlock/tests.rs b/library/std/src/sync/rwlock/tests.rs
index 9cc5e7a3a60..12bb0fbf050 100644
--- a/library/std/src/sync/rwlock/tests.rs
+++ b/library/std/src/sync/rwlock/tests.rs
@@ -1,3 +1,5 @@
+use rand::Rng;
+
 use crate::sync::atomic::{AtomicUsize, Ordering};
 use crate::sync::mpsc::channel;
 use crate::sync::{
@@ -5,7 +7,6 @@ use crate::sync::{
     TryLockError,
 };
 use crate::thread;
-use rand::Rng;
 
 #[derive(Eq, PartialEq, Debug)]
 struct NonCopy(i32);