Skip to content

Commit 7b61403

Browse files
committed
reorganize library/std/src/sync/mod.rs file
Moves things around to make a bit more sense (plus prepare moving `once` out of `poison`. Signed-off-by: Connor Tsui <[email protected]>
1 parent 0758e19 commit 7b61403

File tree

1 file changed

+31
-28
lines changed

1 file changed

+31
-28
lines changed

library/std/src/sync/mod.rs

Lines changed: 31 additions & 28 deletions
Original file line numberDiff line numberDiff line change
@@ -181,7 +181,20 @@ pub use alloc_crate::sync::UniqueArc;
181181
#[stable(feature = "rust1", since = "1.0.0")]
182182
pub use alloc_crate::sync::{Arc, Weak};
183183

184-
// FIXME(sync_nonpoison,sync_poison_mod): remove all `#[doc(inline)]` once the modules are stabilized.
184+
#[unstable(feature = "mpmc_channel", issue = "126840")]
185+
pub mod mpmc;
186+
pub mod mpsc;
187+
188+
// TODO: Make this `self::once::ONCE_INIT`.
189+
#[stable(feature = "rust1", since = "1.0.0")]
190+
#[doc(inline)]
191+
#[expect(deprecated)]
192+
pub use self::poison::ONCE_INIT;
193+
194+
mod barrier;
195+
mod lazy_lock;
196+
mod once_lock;
197+
mod reentrant_lock;
185198

186199
// These exist only in one flavor: no poisoning.
187200
#[stable(feature = "rust1", since = "1.0.0")]
@@ -193,48 +206,38 @@ pub use self::once_lock::OnceLock;
193206
#[unstable(feature = "reentrant_lock", issue = "121440")]
194207
pub use self::reentrant_lock::{ReentrantLock, ReentrantLockGuard};
195208

196-
// These make sense and exist only with poisoning.
209+
// Note: in the future we will change the default version in `std::sync` to the non-poisoning
210+
// version over an edition.
211+
// See https://github.com/rust-lang/rust/issues/134645#issuecomment-3324577500 for more details.
212+
213+
#[unstable(feature = "sync_nonpoison", issue = "134645")]
214+
pub mod nonpoison;
215+
#[unstable(feature = "sync_poison_mod", issue = "134646")]
216+
pub mod poison;
217+
218+
// FIXME(sync_poison_mod): remove all `#[doc(inline)]` once the modules are stabilized.
219+
220+
// These exist only with poisoning.
197221
#[stable(feature = "rust1", since = "1.0.0")]
198222
#[doc(inline)]
199223
pub use self::poison::{LockResult, PoisonError};
200224

201-
// These (should) exist in both flavors: with and without poisoning.
202-
// FIXME(sync_nonpoison): implement nonpoison versions:
203-
// * Mutex (nonpoison_mutex)
204-
// * Condvar (nonpoison_condvar)
205-
// * Once (nonpoison_once)
206-
// * RwLock (nonpoison_rwlock)
225+
// These exist in both flavors: with and without poisoning.
207226
// The historical default is the version with poisoning.
208227
#[stable(feature = "rust1", since = "1.0.0")]
209228
#[doc(inline)]
210229
pub use self::poison::{
211-
Mutex, MutexGuard, TryLockError, TryLockResult,
230+
TryLockError, TryLockResult,
231+
Mutex, MutexGuard,
232+
RwLock, RwLockReadGuard, RwLockWriteGuard,
212233
Condvar,
213234
Once, OnceState,
214-
RwLock, RwLockReadGuard, RwLockWriteGuard,
215235
};
216-
#[stable(feature = "rust1", since = "1.0.0")]
217-
#[doc(inline)]
218-
#[expect(deprecated)]
219-
pub use self::poison::ONCE_INIT;
236+
220237
#[unstable(feature = "mapped_lock_guards", issue = "117108")]
221238
#[doc(inline)]
222239
pub use self::poison::{MappedMutexGuard, MappedRwLockReadGuard, MappedRwLockWriteGuard};
223240

224-
#[unstable(feature = "mpmc_channel", issue = "126840")]
225-
pub mod mpmc;
226-
pub mod mpsc;
227-
228-
#[unstable(feature = "sync_nonpoison", issue = "134645")]
229-
pub mod nonpoison;
230-
#[unstable(feature = "sync_poison_mod", issue = "134646")]
231-
pub mod poison;
232-
233-
mod barrier;
234-
mod lazy_lock;
235-
mod once_lock;
236-
mod reentrant_lock;
237-
238241
/// A type indicating whether a timed wait on a condition variable returned
239242
/// due to a time out or not.
240243
///

0 commit comments

Comments
 (0)