Skip to content

Commit 94ef942

Browse files
Rollup merge of rust-lang#84387 - CDirkx:poison, r=m-ou-se
Move `sys_common::poison` to `sync::poison` `sys_common` should not contain publicly exported types, only platform-independent abstractions on top of `sys`, which `sys_common::poison` is not. There is thus no reason for the module to not live under `sync`.
2 parents 71b03dc + 9cabbd0 commit 94ef942

File tree

6 files changed

+15
-14
lines changed

6 files changed

+15
-14
lines changed

library/std/src/sync/condvar.rs

+1-2
Original file line numberDiff line numberDiff line change
@@ -2,9 +2,8 @@
22
mod tests;
33

44
use crate::fmt;
5-
use crate::sync::{mutex, MutexGuard, PoisonError};
5+
use crate::sync::{mutex, poison, LockResult, MutexGuard, PoisonError};
66
use crate::sys_common::condvar as sys;
7-
use crate::sys_common::poison::{self, LockResult};
87
use crate::time::{Duration, Instant};
98

109
/// A type indicating whether a timed wait on a condition variable returned

library/std/src/sync/mod.rs

+3-2
Original file line numberDiff line numberDiff line change
@@ -166,14 +166,15 @@ pub use self::mutex::{Mutex, MutexGuard};
166166
#[allow(deprecated)]
167167
pub use self::once::{Once, OnceState, ONCE_INIT};
168168
#[stable(feature = "rust1", since = "1.0.0")]
169-
pub use self::rwlock::{RwLock, RwLockReadGuard, RwLockWriteGuard};
169+
pub use self::poison::{LockResult, PoisonError, TryLockError, TryLockResult};
170170
#[stable(feature = "rust1", since = "1.0.0")]
171-
pub use crate::sys_common::poison::{LockResult, PoisonError, TryLockError, TryLockResult};
171+
pub use self::rwlock::{RwLock, RwLockReadGuard, RwLockWriteGuard};
172172

173173
pub mod mpsc;
174174

175175
mod barrier;
176176
mod condvar;
177177
mod mutex;
178178
mod once;
179+
mod poison;
179180
mod rwlock;

library/std/src/sync/mutex.rs

+1-1
Original file line numberDiff line numberDiff line change
@@ -6,8 +6,8 @@ use crate::fmt;
66
use crate::mem;
77
use crate::ops::{Deref, DerefMut};
88
use crate::ptr;
9+
use crate::sync::{poison, LockResult, TryLockError, TryLockResult};
910
use crate::sys_common::mutex as sys;
10-
use crate::sys_common::poison::{self, LockResult, TryLockError, TryLockResult};
1111

1212
/// A mutual exclusion primitive useful for protecting shared data
1313
///

library/std/src/sys_common/poison.rs library/std/src/sync/poison.rs

+9-7
Original file line numberDiff line numberDiff line change
@@ -3,9 +3,6 @@ use crate::fmt;
33
use crate::sync::atomic::{AtomicBool, Ordering};
44
use crate::thread;
55

6-
#[allow(unused_imports)] // for intra-doc links
7-
use crate::sync::{Mutex, RwLock};
8-
96
pub struct Flag {
107
failed: AtomicBool,
118
}
@@ -80,6 +77,8 @@ pub struct Guard {
8077
/// }
8178
/// };
8279
/// ```
80+
/// [`Mutex`]: crate::sync::Mutex
81+
/// [`RwLock`]: crate::sync::RwLock
8382
#[stable(feature = "rust1", since = "1.0.0")]
8483
pub struct PoisonError<T> {
8584
guard: T,
@@ -89,9 +88,11 @@ pub struct PoisonError<T> {
8988
/// can occur while trying to acquire a lock, from the [`try_lock`] method on a
9089
/// [`Mutex`] or the [`try_read`] and [`try_write`] methods on an [`RwLock`].
9190
///
92-
/// [`try_lock`]: Mutex::try_lock
93-
/// [`try_read`]: RwLock::try_read
94-
/// [`try_write`]: RwLock::try_write
91+
/// [`try_lock`]: crate::sync::Mutex::try_lock
92+
/// [`try_read`]: crate::sync::RwLock::try_read
93+
/// [`try_write`]: crate::sync::RwLock::try_write
94+
/// [`Mutex`]: crate::sync::Mutex
95+
/// [`RwLock`]: crate::sync::RwLock
9596
#[stable(feature = "rust1", since = "1.0.0")]
9697
pub enum TryLockError<T> {
9798
/// The lock could not be acquired because another thread failed while holding
@@ -149,7 +150,8 @@ impl<T> Error for PoisonError<T> {
149150
impl<T> PoisonError<T> {
150151
/// Creates a `PoisonError`.
151152
///
152-
/// This is generally created by methods like [`Mutex::lock`] or [`RwLock::read`].
153+
/// This is generally created by methods like [`Mutex::lock`](crate::sync::Mutex::lock)
154+
/// or [`RwLock::read`](crate::sync::RwLock::read).
153155
#[stable(feature = "sync_poison", since = "1.2.0")]
154156
pub fn new(guard: T) -> PoisonError<T> {
155157
PoisonError { guard }

library/std/src/sync/rwlock.rs

+1-1
Original file line numberDiff line numberDiff line change
@@ -6,7 +6,7 @@ use crate::fmt;
66
use crate::mem;
77
use crate::ops::{Deref, DerefMut};
88
use crate::ptr;
9-
use crate::sys_common::poison::{self, LockResult, TryLockError, TryLockResult};
9+
use crate::sync::{poison, LockResult, TryLockError, TryLockResult};
1010
use crate::sys_common::rwlock as sys;
1111

1212
/// A reader-writer lock

library/std/src/sys_common/mod.rs

-1
Original file line numberDiff line numberDiff line change
@@ -59,7 +59,6 @@ pub mod mutex;
5959
// when generating documentation.
6060
#[cfg(any(doc, not(windows)))]
6161
pub mod os_str_bytes;
62-
pub mod poison;
6362
pub mod process;
6463
pub mod remutex;
6564
pub mod rwlock;

0 commit comments

Comments
 (0)