Skip to content

Commit

Permalink
make Condvar, Mutex, RwLock const constructors work with unsupported …
Browse files Browse the repository at this point in the history
…impl
  • Loading branch information
japaric committed Jun 27, 2022
1 parent fc96600 commit 513eda0
Show file tree
Hide file tree
Showing 7 changed files with 7 additions and 0 deletions.
1 change: 1 addition & 0 deletions library/std/src/sys/unsupported/locks/condvar.rs
Original file line number Diff line number Diff line change
Expand Up @@ -7,6 +7,7 @@ pub type MovableCondvar = Condvar;

impl Condvar {
#[inline]
#[rustc_const_stable(feature = "const_locks", since = "1.63.0")]
pub const fn new() -> Condvar {
Condvar {}
}
Expand Down
1 change: 1 addition & 0 deletions library/std/src/sys/unsupported/locks/mutex.rs
Original file line number Diff line number Diff line change
Expand Up @@ -12,6 +12,7 @@ unsafe impl Sync for Mutex {} // no threads on this platform

impl Mutex {
#[inline]
#[rustc_const_stable(feature = "const_locks", since = "1.63.0")]
pub const fn new() -> Mutex {
Mutex { locked: Cell::new(false) }
}
Expand Down
1 change: 1 addition & 0 deletions library/std/src/sys/unsupported/locks/rwlock.rs
Original file line number Diff line number Diff line change
Expand Up @@ -12,6 +12,7 @@ unsafe impl Sync for RwLock {} // no threads on this platform

impl RwLock {
#[inline]
#[rustc_const_stable(feature = "const_locks", since = "1.63.0")]
pub const fn new() -> RwLock {
RwLock { mode: Cell::new(0) }
}
Expand Down
1 change: 1 addition & 0 deletions library/std/src/sys_common/condvar.rs
Original file line number Diff line number Diff line change
Expand Up @@ -15,6 +15,7 @@ pub struct Condvar {
impl Condvar {
/// Creates a new condition variable for use.
#[inline]
#[rustc_const_stable(feature = "const_locks", since = "1.63.0")]
pub const fn new() -> Self {
Self { inner: imp::MovableCondvar::new(), check: CondvarCheck::new() }
}
Expand Down
1 change: 1 addition & 0 deletions library/std/src/sys_common/condvar/check.rs
Original file line number Diff line number Diff line change
Expand Up @@ -50,6 +50,7 @@ pub struct NoCheck;

#[allow(dead_code)]
impl NoCheck {
#[rustc_const_stable(feature = "const_locks", since = "1.63.0")]
pub const fn new() -> Self {
Self
}
Expand Down
1 change: 1 addition & 0 deletions library/std/src/sys_common/mutex.rs
Original file line number Diff line number Diff line change
Expand Up @@ -61,6 +61,7 @@ unsafe impl Sync for MovableMutex {}
impl MovableMutex {
/// Creates a new mutex.
#[inline]
#[rustc_const_stable(feature = "const_locks", since = "1.63.0")]
pub const fn new() -> Self {
Self(imp::MovableMutex::new())
}
Expand Down
1 change: 1 addition & 0 deletions library/std/src/sys_common/rwlock.rs
Original file line number Diff line number Diff line change
Expand Up @@ -75,6 +75,7 @@ pub struct MovableRwLock(imp::MovableRwLock);
impl MovableRwLock {
/// Creates a new reader-writer lock for use.
#[inline]
#[rustc_const_stable(feature = "const_locks", since = "1.63.0")]
pub const fn new() -> Self {
Self(imp::MovableRwLock::new())
}
Expand Down

0 comments on commit 513eda0

Please sign in to comment.