Skip to content

Commit

Permalink
Rollup merge of rust-lang#84387 - CDirkx:poison, r=m-ou-se
Browse files Browse the repository at this point in the history
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`.

Part of rust-lang#84187.
  • Loading branch information
JohnTitor authored Apr 23, 2021
2 parents 44615e2 + 9cabbd0 commit a456475
Show file tree
Hide file tree
Showing 6 changed files with 15 additions and 14 deletions.
3 changes: 1 addition & 2 deletions library/std/src/sync/condvar.rs
Original file line number Diff line number Diff line change
Expand Up @@ -2,9 +2,8 @@
mod tests;

use crate::fmt;
use crate::sync::{mutex, MutexGuard, PoisonError};
use crate::sync::{mutex, poison, LockResult, MutexGuard, PoisonError};
use crate::sys_common::condvar as sys;
use crate::sys_common::poison::{self, LockResult};
use crate::time::{Duration, Instant};

/// A type indicating whether a timed wait on a condition variable returned
Expand Down
5 changes: 3 additions & 2 deletions library/std/src/sync/mod.rs
Original file line number Diff line number Diff line change
Expand Up @@ -166,14 +166,15 @@ pub use self::mutex::{Mutex, MutexGuard};
#[allow(deprecated)]
pub use self::once::{Once, OnceState, ONCE_INIT};
#[stable(feature = "rust1", since = "1.0.0")]
pub use self::rwlock::{RwLock, RwLockReadGuard, RwLockWriteGuard};
pub use self::poison::{LockResult, PoisonError, TryLockError, TryLockResult};
#[stable(feature = "rust1", since = "1.0.0")]
pub use crate::sys_common::poison::{LockResult, PoisonError, TryLockError, TryLockResult};
pub use self::rwlock::{RwLock, RwLockReadGuard, RwLockWriteGuard};

pub mod mpsc;

mod barrier;
mod condvar;
mod mutex;
mod once;
mod poison;
mod rwlock;
2 changes: 1 addition & 1 deletion library/std/src/sync/mutex.rs
Original file line number Diff line number Diff line change
Expand Up @@ -6,8 +6,8 @@ use crate::fmt;
use crate::mem;
use crate::ops::{Deref, DerefMut};
use crate::ptr;
use crate::sync::{poison, LockResult, TryLockError, TryLockResult};
use crate::sys_common::mutex as sys;
use crate::sys_common::poison::{self, LockResult, TryLockError, TryLockResult};

/// A mutual exclusion primitive useful for protecting shared data
///
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -3,9 +3,6 @@ use crate::fmt;
use crate::sync::atomic::{AtomicBool, Ordering};
use crate::thread;

#[allow(unused_imports)] // for intra-doc links
use crate::sync::{Mutex, RwLock};

pub struct Flag {
failed: AtomicBool,
}
Expand Down Expand Up @@ -80,6 +77,8 @@ pub struct Guard {
/// }
/// };
/// ```
/// [`Mutex`]: crate::sync::Mutex
/// [`RwLock`]: crate::sync::RwLock
#[stable(feature = "rust1", since = "1.0.0")]
pub struct PoisonError<T> {
guard: T,
Expand All @@ -89,9 +88,11 @@ pub struct PoisonError<T> {
/// can occur while trying to acquire a lock, from the [`try_lock`] method on a
/// [`Mutex`] or the [`try_read`] and [`try_write`] methods on an [`RwLock`].
///
/// [`try_lock`]: Mutex::try_lock
/// [`try_read`]: RwLock::try_read
/// [`try_write`]: RwLock::try_write
/// [`try_lock`]: crate::sync::Mutex::try_lock
/// [`try_read`]: crate::sync::RwLock::try_read
/// [`try_write`]: crate::sync::RwLock::try_write
/// [`Mutex`]: crate::sync::Mutex
/// [`RwLock`]: crate::sync::RwLock
#[stable(feature = "rust1", since = "1.0.0")]
pub enum TryLockError<T> {
/// The lock could not be acquired because another thread failed while holding
Expand Down Expand Up @@ -149,7 +150,8 @@ impl<T> Error for PoisonError<T> {
impl<T> PoisonError<T> {
/// Creates a `PoisonError`.
///
/// This is generally created by methods like [`Mutex::lock`] or [`RwLock::read`].
/// This is generally created by methods like [`Mutex::lock`](crate::sync::Mutex::lock)
/// or [`RwLock::read`](crate::sync::RwLock::read).
#[stable(feature = "sync_poison", since = "1.2.0")]
pub fn new(guard: T) -> PoisonError<T> {
PoisonError { guard }
Expand Down
2 changes: 1 addition & 1 deletion library/std/src/sync/rwlock.rs
Original file line number Diff line number Diff line change
Expand Up @@ -6,7 +6,7 @@ use crate::fmt;
use crate::mem;
use crate::ops::{Deref, DerefMut};
use crate::ptr;
use crate::sys_common::poison::{self, LockResult, TryLockError, TryLockResult};
use crate::sync::{poison, LockResult, TryLockError, TryLockResult};
use crate::sys_common::rwlock as sys;

/// A reader-writer lock
Expand Down
1 change: 0 additions & 1 deletion library/std/src/sys_common/mod.rs
Original file line number Diff line number Diff line change
Expand Up @@ -59,7 +59,6 @@ pub mod mutex;
// when generating documentation.
#[cfg(any(doc, not(windows)))]
pub mod os_str_bytes;
pub mod poison;
pub mod process;
pub mod remutex;
pub mod rwlock;
Expand Down

0 comments on commit a456475

Please sign in to comment.