Skip to content

Commit e20fabb

Browse files
committed
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)
2 parents e58621a + 513eda0 commit e20fabb

File tree

7 files changed

+7
-0
lines changed

7 files changed

+7
-0
lines changed

library/std/src/sys/unsupported/locks/condvar.rs

+1
Original file line numberDiff line numberDiff line change
@@ -7,6 +7,7 @@ pub type MovableCondvar = Condvar;
77

88
impl Condvar {
99
#[inline]
10+
#[rustc_const_stable(feature = "const_locks", since = "1.63.0")]
1011
pub const fn new() -> Condvar {
1112
Condvar {}
1213
}

library/std/src/sys/unsupported/locks/mutex.rs

+1
Original file line numberDiff line numberDiff line change
@@ -12,6 +12,7 @@ unsafe impl Sync for Mutex {} // no threads on this platform
1212

1313
impl Mutex {
1414
#[inline]
15+
#[rustc_const_stable(feature = "const_locks", since = "1.63.0")]
1516
pub const fn new() -> Mutex {
1617
Mutex { locked: Cell::new(false) }
1718
}

library/std/src/sys/unsupported/locks/rwlock.rs

+1
Original file line numberDiff line numberDiff line change
@@ -12,6 +12,7 @@ unsafe impl Sync for RwLock {} // no threads on this platform
1212

1313
impl RwLock {
1414
#[inline]
15+
#[rustc_const_stable(feature = "const_locks", since = "1.63.0")]
1516
pub const fn new() -> RwLock {
1617
RwLock { mode: Cell::new(0) }
1718
}

library/std/src/sys_common/condvar.rs

+1
Original file line numberDiff line numberDiff line change
@@ -15,6 +15,7 @@ pub struct Condvar {
1515
impl Condvar {
1616
/// Creates a new condition variable for use.
1717
#[inline]
18+
#[rustc_const_stable(feature = "const_locks", since = "1.63.0")]
1819
pub const fn new() -> Self {
1920
Self { inner: imp::MovableCondvar::new(), check: CondvarCheck::new() }
2021
}

library/std/src/sys_common/condvar/check.rs

+1
Original file line numberDiff line numberDiff line change
@@ -50,6 +50,7 @@ pub struct NoCheck;
5050

5151
#[allow(dead_code)]
5252
impl NoCheck {
53+
#[rustc_const_stable(feature = "const_locks", since = "1.63.0")]
5354
pub const fn new() -> Self {
5455
Self
5556
}

library/std/src/sys_common/mutex.rs

+1
Original file line numberDiff line numberDiff line change
@@ -61,6 +61,7 @@ unsafe impl Sync for MovableMutex {}
6161
impl MovableMutex {
6262
/// Creates a new mutex.
6363
#[inline]
64+
#[rustc_const_stable(feature = "const_locks", since = "1.63.0")]
6465
pub const fn new() -> Self {
6566
Self(imp::MovableMutex::new())
6667
}

library/std/src/sys_common/rwlock.rs

+1
Original file line numberDiff line numberDiff line change
@@ -15,6 +15,7 @@ pub struct MovableRwLock(imp::MovableRwLock);
1515
impl MovableRwLock {
1616
/// Creates a new reader-writer lock for use.
1717
#[inline]
18+
#[rustc_const_stable(feature = "const_locks", since = "1.63.0")]
1819
pub const fn new() -> Self {
1920
Self(imp::MovableRwLock::new())
2021
}

0 commit comments

Comments
 (0)