mirror of
https://github.com/rust-lang/rust.git
synced 2024-11-22 23:04:33 +00:00
Auto merge of #98457 - japaric:gh98378, r=m-ou-se
make Condvar, Mutex, RwLock const constructors work with the `unsupported` impl applying this patch locally to the `rust-src` component fixes #98378 however, the solution seems wrong to me because PR #97791 didn't add any `rustc_const_stable` attribute to underlying implementations like `std::sys::unix::futex`, so I must be missing something about how const-stability is checked ... maybe the `restricted_std` feature (gate?) has an effect? fixes #98378 fixes #98293 (probably)
This commit is contained in:
commit
e20fabb0d0
@ -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 {}
|
||||
}
|
||||
|
@ -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) }
|
||||
}
|
||||
|
@ -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) }
|
||||
}
|
||||
|
@ -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() }
|
||||
}
|
||||
|
@ -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
|
||||
}
|
||||
|
@ -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())
|
||||
}
|
||||
|
@ -15,6 +15,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())
|
||||
}
|
||||
|
Loading…
Reference in New Issue
Block a user