Skip to content

Commit f559d61

Browse files
committed
Auto merge of rust-lang#131288 - matthiaskrgr:rollup-h0t0v2h, r=matthiaskrgr
Rollup of 5 pull requests Successful merges: - rust-lang#130428 (Stabilize `const_slice_split_at_mut` and `const_slice_first_last_chunk`) - rust-lang#131094 (std: replace `LazyBox` with `OnceBox`) - rust-lang#131256 (move f16/f128 const fn under f16/f128 feature gate) - rust-lang#131278 (remove outdated contribution direction) - rust-lang#131286 (Miri subtree update) r? `@ghost` `@rustbot` modify labels: rollup
2 parents 5a4ee43 + 72acacf commit f559d61

Some content is hidden

Large Commits have some content hidden by default. Use the searchbox below for content that may be hidden.

61 files changed

+1516
-724
lines changed

library/core/src/lib.rs

-3
Original file line numberDiff line numberDiff line change
@@ -146,7 +146,6 @@
146146
#![feature(const_size_of_val)]
147147
#![feature(const_size_of_val_raw)]
148148
#![feature(const_slice_from_ref)]
149-
#![feature(const_slice_split_at_mut)]
150149
#![feature(const_strict_overflow_ops)]
151150
#![feature(const_swap)]
152151
#![feature(const_try)]
@@ -158,8 +157,6 @@
158157
#![feature(coverage_attribute)]
159158
#![feature(do_not_recommend)]
160159
#![feature(duration_consts_float)]
161-
#![feature(f128_const)]
162-
#![feature(f16_const)]
163160
#![feature(internal_impls_macro)]
164161
#![feature(ip)]
165162
#![feature(is_ascii_octdigit)]

library/core/src/num/f128.rs

+8-8
Original file line numberDiff line numberDiff line change
@@ -910,7 +910,7 @@ impl f128 {
910910
/// ```
911911
#[inline]
912912
#[unstable(feature = "f128", issue = "116909")]
913-
#[rustc_const_unstable(feature = "f128_const", issue = "116909")]
913+
#[rustc_const_unstable(feature = "f128", issue = "116909")]
914914
#[must_use = "this returns the result of the operation, without modifying the original"]
915915
pub const fn to_bits(self) -> u128 {
916916
// SAFETY: `u128` is a plain old datatype so we can always transmute to it.
@@ -959,7 +959,7 @@ impl f128 {
959959
#[inline]
960960
#[must_use]
961961
#[unstable(feature = "f128", issue = "116909")]
962-
#[rustc_const_unstable(feature = "f128_const", issue = "116909")]
962+
#[rustc_const_unstable(feature = "f128", issue = "116909")]
963963
pub const fn from_bits(v: u128) -> Self {
964964
// It turns out the safety issues with sNaN were overblown! Hooray!
965965
// SAFETY: `u128` is a plain old datatype so we can always transmute from it.
@@ -986,7 +986,7 @@ impl f128 {
986986
/// ```
987987
#[inline]
988988
#[unstable(feature = "f128", issue = "116909")]
989-
#[rustc_const_unstable(feature = "f128_const", issue = "116909")]
989+
#[rustc_const_unstable(feature = "f128", issue = "116909")]
990990
#[must_use = "this returns the result of the operation, without modifying the original"]
991991
pub const fn to_be_bytes(self) -> [u8; 16] {
992992
self.to_bits().to_be_bytes()
@@ -1012,7 +1012,7 @@ impl f128 {
10121012
/// ```
10131013
#[inline]
10141014
#[unstable(feature = "f128", issue = "116909")]
1015-
#[rustc_const_unstable(feature = "f128_const", issue = "116909")]
1015+
#[rustc_const_unstable(feature = "f128", issue = "116909")]
10161016
#[must_use = "this returns the result of the operation, without modifying the original"]
10171017
pub const fn to_le_bytes(self) -> [u8; 16] {
10181018
self.to_bits().to_le_bytes()
@@ -1049,7 +1049,7 @@ impl f128 {
10491049
/// ```
10501050
#[inline]
10511051
#[unstable(feature = "f128", issue = "116909")]
1052-
#[rustc_const_unstable(feature = "f128_const", issue = "116909")]
1052+
#[rustc_const_unstable(feature = "f128", issue = "116909")]
10531053
#[must_use = "this returns the result of the operation, without modifying the original"]
10541054
pub const fn to_ne_bytes(self) -> [u8; 16] {
10551055
self.to_bits().to_ne_bytes()
@@ -1077,7 +1077,7 @@ impl f128 {
10771077
#[inline]
10781078
#[must_use]
10791079
#[unstable(feature = "f128", issue = "116909")]
1080-
#[rustc_const_unstable(feature = "f128_const", issue = "116909")]
1080+
#[rustc_const_unstable(feature = "f128", issue = "116909")]
10811081
pub const fn from_be_bytes(bytes: [u8; 16]) -> Self {
10821082
Self::from_bits(u128::from_be_bytes(bytes))
10831083
}
@@ -1104,7 +1104,7 @@ impl f128 {
11041104
#[inline]
11051105
#[must_use]
11061106
#[unstable(feature = "f128", issue = "116909")]
1107-
#[rustc_const_unstable(feature = "f128_const", issue = "116909")]
1107+
#[rustc_const_unstable(feature = "f128", issue = "116909")]
11081108
pub const fn from_le_bytes(bytes: [u8; 16]) -> Self {
11091109
Self::from_bits(u128::from_le_bytes(bytes))
11101110
}
@@ -1141,7 +1141,7 @@ impl f128 {
11411141
#[inline]
11421142
#[must_use]
11431143
#[unstable(feature = "f128", issue = "116909")]
1144-
#[rustc_const_unstable(feature = "f128_const", issue = "116909")]
1144+
#[rustc_const_unstable(feature = "f128", issue = "116909")]
11451145
pub const fn from_ne_bytes(bytes: [u8; 16]) -> Self {
11461146
Self::from_bits(u128::from_ne_bytes(bytes))
11471147
}

library/core/src/num/f16.rs

+8-8
Original file line numberDiff line numberDiff line change
@@ -896,7 +896,7 @@ impl f16 {
896896
/// ```
897897
#[inline]
898898
#[unstable(feature = "f16", issue = "116909")]
899-
#[rustc_const_unstable(feature = "f16_const", issue = "116909")]
899+
#[rustc_const_unstable(feature = "f16", issue = "116909")]
900900
#[must_use = "this returns the result of the operation, without modifying the original"]
901901
pub const fn to_bits(self) -> u16 {
902902
// SAFETY: `u16` is a plain old datatype so we can always transmute to it.
@@ -944,7 +944,7 @@ impl f16 {
944944
#[inline]
945945
#[must_use]
946946
#[unstable(feature = "f16", issue = "116909")]
947-
#[rustc_const_unstable(feature = "f16_const", issue = "116909")]
947+
#[rustc_const_unstable(feature = "f16", issue = "116909")]
948948
pub const fn from_bits(v: u16) -> Self {
949949
// It turns out the safety issues with sNaN were overblown! Hooray!
950950
// SAFETY: `u16` is a plain old datatype so we can always transmute from it.
@@ -970,7 +970,7 @@ impl f16 {
970970
/// ```
971971
#[inline]
972972
#[unstable(feature = "f16", issue = "116909")]
973-
#[rustc_const_unstable(feature = "f16_const", issue = "116909")]
973+
#[rustc_const_unstable(feature = "f16", issue = "116909")]
974974
#[must_use = "this returns the result of the operation, without modifying the original"]
975975
pub const fn to_be_bytes(self) -> [u8; 2] {
976976
self.to_bits().to_be_bytes()
@@ -995,7 +995,7 @@ impl f16 {
995995
/// ```
996996
#[inline]
997997
#[unstable(feature = "f16", issue = "116909")]
998-
#[rustc_const_unstable(feature = "f16_const", issue = "116909")]
998+
#[rustc_const_unstable(feature = "f16", issue = "116909")]
999999
#[must_use = "this returns the result of the operation, without modifying the original"]
10001000
pub const fn to_le_bytes(self) -> [u8; 2] {
10011001
self.to_bits().to_le_bytes()
@@ -1033,7 +1033,7 @@ impl f16 {
10331033
/// ```
10341034
#[inline]
10351035
#[unstable(feature = "f16", issue = "116909")]
1036-
#[rustc_const_unstable(feature = "f16_const", issue = "116909")]
1036+
#[rustc_const_unstable(feature = "f16", issue = "116909")]
10371037
#[must_use = "this returns the result of the operation, without modifying the original"]
10381038
pub const fn to_ne_bytes(self) -> [u8; 2] {
10391039
self.to_bits().to_ne_bytes()
@@ -1057,7 +1057,7 @@ impl f16 {
10571057
#[inline]
10581058
#[must_use]
10591059
#[unstable(feature = "f16", issue = "116909")]
1060-
#[rustc_const_unstable(feature = "f16_const", issue = "116909")]
1060+
#[rustc_const_unstable(feature = "f16", issue = "116909")]
10611061
pub const fn from_be_bytes(bytes: [u8; 2]) -> Self {
10621062
Self::from_bits(u16::from_be_bytes(bytes))
10631063
}
@@ -1080,7 +1080,7 @@ impl f16 {
10801080
#[inline]
10811081
#[must_use]
10821082
#[unstable(feature = "f16", issue = "116909")]
1083-
#[rustc_const_unstable(feature = "f16_const", issue = "116909")]
1083+
#[rustc_const_unstable(feature = "f16", issue = "116909")]
10841084
pub const fn from_le_bytes(bytes: [u8; 2]) -> Self {
10851085
Self::from_bits(u16::from_le_bytes(bytes))
10861086
}
@@ -1114,7 +1114,7 @@ impl f16 {
11141114
#[inline]
11151115
#[must_use]
11161116
#[unstable(feature = "f16", issue = "116909")]
1117-
#[rustc_const_unstable(feature = "f16_const", issue = "116909")]
1117+
#[rustc_const_unstable(feature = "f16", issue = "116909")]
11181118
pub const fn from_ne_bytes(bytes: [u8; 2]) -> Self {
11191119
Self::from_bits(u16::from_ne_bytes(bytes))
11201120
}

library/core/src/slice/mod.rs

+14-7
Original file line numberDiff line numberDiff line change
@@ -356,7 +356,8 @@ impl<T> [T] {
356356
/// ```
357357
#[inline]
358358
#[stable(feature = "slice_first_last_chunk", since = "1.77.0")]
359-
#[rustc_const_unstable(feature = "const_slice_first_last_chunk", issue = "111774")]
359+
#[rustc_const_stable(feature = "const_slice_first_last_chunk", since = "CURRENT_RUSTC_VERSION")]
360+
#[cfg_attr(bootstrap, rustc_allow_const_fn_unstable(const_mut_refs))]
360361
pub const fn first_chunk_mut<const N: usize>(&mut self) -> Option<&mut [T; N]> {
361362
if self.len() < N {
362363
None
@@ -421,7 +422,8 @@ impl<T> [T] {
421422
/// ```
422423
#[inline]
423424
#[stable(feature = "slice_first_last_chunk", since = "1.77.0")]
424-
#[rustc_const_unstable(feature = "const_slice_first_last_chunk", issue = "111774")]
425+
#[rustc_const_stable(feature = "const_slice_first_last_chunk", since = "CURRENT_RUSTC_VERSION")]
426+
#[cfg_attr(bootstrap, rustc_allow_const_fn_unstable(const_mut_refs))]
425427
pub const fn split_first_chunk_mut<const N: usize>(
426428
&mut self,
427429
) -> Option<(&mut [T; N], &mut [T])> {
@@ -491,7 +493,8 @@ impl<T> [T] {
491493
/// ```
492494
#[inline]
493495
#[stable(feature = "slice_first_last_chunk", since = "1.77.0")]
494-
#[rustc_const_unstable(feature = "const_slice_first_last_chunk", issue = "111774")]
496+
#[rustc_const_stable(feature = "const_slice_first_last_chunk", since = "CURRENT_RUSTC_VERSION")]
497+
#[cfg_attr(bootstrap, rustc_allow_const_fn_unstable(const_mut_refs))]
495498
pub const fn split_last_chunk_mut<const N: usize>(
496499
&mut self,
497500
) -> Option<(&mut [T], &mut [T; N])> {
@@ -560,7 +563,8 @@ impl<T> [T] {
560563
/// ```
561564
#[inline]
562565
#[stable(feature = "slice_first_last_chunk", since = "1.77.0")]
563-
#[rustc_const_unstable(feature = "const_slice_first_last_chunk", issue = "111774")]
566+
#[rustc_const_stable(feature = "const_slice_first_last_chunk", since = "CURRENT_RUSTC_VERSION")]
567+
#[cfg_attr(bootstrap, rustc_allow_const_fn_unstable(const_mut_refs))]
564568
pub const fn last_chunk_mut<const N: usize>(&mut self) -> Option<&mut [T; N]> {
565569
if self.len() < N {
566570
None
@@ -1903,7 +1907,8 @@ impl<T> [T] {
19031907
#[inline]
19041908
#[track_caller]
19051909
#[must_use]
1906-
#[rustc_const_unstable(feature = "const_slice_split_at_mut", issue = "101804")]
1910+
#[rustc_const_stable(feature = "const_slice_split_at_mut", since = "CURRENT_RUSTC_VERSION")]
1911+
#[cfg_attr(bootstrap, rustc_allow_const_fn_unstable(const_mut_refs))]
19071912
pub const fn split_at_mut(&mut self, mid: usize) -> (&mut [T], &mut [T]) {
19081913
match self.split_at_mut_checked(mid) {
19091914
Some(pair) => pair,
@@ -2005,7 +2010,8 @@ impl<T> [T] {
20052010
/// assert_eq!(v, [1, 2, 3, 4, 5, 6]);
20062011
/// ```
20072012
#[stable(feature = "slice_split_at_unchecked", since = "1.79.0")]
2008-
#[rustc_const_unstable(feature = "const_slice_split_at_mut", issue = "101804")]
2013+
#[rustc_const_stable(feature = "const_slice_split_at_mut", since = "CURRENT_RUSTC_VERSION")]
2014+
#[cfg_attr(bootstrap, rustc_allow_const_fn_unstable(const_mut_refs))]
20092015
#[inline]
20102016
#[must_use]
20112017
pub const unsafe fn split_at_mut_unchecked(&mut self, mid: usize) -> (&mut [T], &mut [T]) {
@@ -2105,7 +2111,8 @@ impl<T> [T] {
21052111
/// assert_eq!(None, v.split_at_mut_checked(7));
21062112
/// ```
21072113
#[stable(feature = "split_at_checked", since = "1.80.0")]
2108-
#[rustc_const_unstable(feature = "const_slice_split_at_mut", issue = "101804")]
2114+
#[rustc_const_stable(feature = "const_slice_split_at_mut", since = "CURRENT_RUSTC_VERSION")]
2115+
#[cfg_attr(bootstrap, rustc_allow_const_fn_unstable(const_mut_refs))]
21092116
#[inline]
21102117
#[must_use]
21112118
pub const fn split_at_mut_checked(&mut self, mid: usize) -> Option<(&mut [T], &mut [T])> {

library/std/src/sys/sync/condvar/mod.rs

+4-4
Original file line numberDiff line numberDiff line change
@@ -12,7 +12,10 @@ cfg_if::cfg_if! {
1212
))] {
1313
mod futex;
1414
pub use futex::Condvar;
15-
} else if #[cfg(target_family = "unix")] {
15+
} else if #[cfg(any(
16+
target_family = "unix",
17+
target_os = "teeos",
18+
))] {
1619
mod pthread;
1720
pub use pthread::Condvar;
1821
} else if #[cfg(all(target_os = "windows", target_vendor = "win7"))] {
@@ -24,9 +27,6 @@ cfg_if::cfg_if! {
2427
} else if #[cfg(target_os = "solid_asp3")] {
2528
mod itron;
2629
pub use itron::Condvar;
27-
} else if #[cfg(target_os = "teeos")] {
28-
mod teeos;
29-
pub use teeos::Condvar;
3030
} else if #[cfg(target_os = "xous")] {
3131
mod xous;
3232
pub use xous::Condvar;

library/std/src/sys/sync/condvar/pthread.rs

+18-20
Original file line numberDiff line numberDiff line change
@@ -2,31 +2,25 @@ use crate::cell::UnsafeCell;
22
use crate::ptr;
33
use crate::sync::atomic::AtomicPtr;
44
use crate::sync::atomic::Ordering::Relaxed;
5-
use crate::sys::sync::{Mutex, mutex};
5+
use crate::sys::sync::{Mutex, OnceBox};
66
#[cfg(not(target_os = "nto"))]
77
use crate::sys::time::TIMESPEC_MAX;
88
#[cfg(target_os = "nto")]
99
use crate::sys::time::TIMESPEC_MAX_CAPPED;
10-
use crate::sys_common::lazy_box::{LazyBox, LazyInit};
1110
use crate::time::Duration;
1211

1312
struct AllocatedCondvar(UnsafeCell<libc::pthread_cond_t>);
1413

1514
pub struct Condvar {
16-
inner: LazyBox<AllocatedCondvar>,
15+
inner: OnceBox<AllocatedCondvar>,
1716
mutex: AtomicPtr<libc::pthread_mutex_t>,
1817
}
1918

20-
#[inline]
21-
fn raw(c: &Condvar) -> *mut libc::pthread_cond_t {
22-
c.inner.0.get()
23-
}
24-
2519
unsafe impl Send for AllocatedCondvar {}
2620
unsafe impl Sync for AllocatedCondvar {}
2721

28-
impl LazyInit for AllocatedCondvar {
29-
fn init() -> Box<Self> {
22+
impl AllocatedCondvar {
23+
fn new() -> Box<Self> {
3024
let condvar = Box::new(AllocatedCondvar(UnsafeCell::new(libc::PTHREAD_COND_INITIALIZER)));
3125

3226
cfg_if::cfg_if! {
@@ -37,7 +31,7 @@ impl LazyInit for AllocatedCondvar {
3731
target_vendor = "apple",
3832
))] {
3933
// `pthread_condattr_setclock` is unfortunately not supported on these platforms.
40-
} else if #[cfg(any(target_os = "espidf", target_os = "horizon"))] {
34+
} else if #[cfg(any(target_os = "espidf", target_os = "horizon", target_os = "teeos"))] {
4135
// NOTE: ESP-IDF's PTHREAD_COND_INITIALIZER support is not released yet
4236
// So on that platform, init() should always be called
4337
// Moreover, that platform does not have pthread_condattr_setclock support,
@@ -82,7 +76,11 @@ impl Drop for AllocatedCondvar {
8276

8377
impl Condvar {
8478
pub const fn new() -> Condvar {
85-
Condvar { inner: LazyBox::new(), mutex: AtomicPtr::new(ptr::null_mut()) }
79+
Condvar { inner: OnceBox::new(), mutex: AtomicPtr::new(ptr::null_mut()) }
80+
}
81+
82+
fn get(&self) -> *mut libc::pthread_cond_t {
83+
self.inner.get_or_init(AllocatedCondvar::new).0.get()
8684
}
8785

8886
#[inline]
@@ -98,21 +96,21 @@ impl Condvar {
9896

9997
#[inline]
10098
pub fn notify_one(&self) {
101-
let r = unsafe { libc::pthread_cond_signal(raw(self)) };
99+
let r = unsafe { libc::pthread_cond_signal(self.get()) };
102100
debug_assert_eq!(r, 0);
103101
}
104102

105103
#[inline]
106104
pub fn notify_all(&self) {
107-
let r = unsafe { libc::pthread_cond_broadcast(raw(self)) };
105+
let r = unsafe { libc::pthread_cond_broadcast(self.get()) };
108106
debug_assert_eq!(r, 0);
109107
}
110108

111109
#[inline]
112110
pub unsafe fn wait(&self, mutex: &Mutex) {
113-
let mutex = mutex::raw(mutex);
111+
let mutex = mutex.get_assert_locked();
114112
self.verify(mutex);
115-
let r = libc::pthread_cond_wait(raw(self), mutex);
113+
let r = libc::pthread_cond_wait(self.get(), mutex);
116114
debug_assert_eq!(r, 0);
117115
}
118116

@@ -129,7 +127,7 @@ impl Condvar {
129127
pub unsafe fn wait_timeout(&self, mutex: &Mutex, dur: Duration) -> bool {
130128
use crate::sys::time::Timespec;
131129

132-
let mutex = mutex::raw(mutex);
130+
let mutex = mutex.get_assert_locked();
133131
self.verify(mutex);
134132

135133
#[cfg(not(target_os = "nto"))]
@@ -144,7 +142,7 @@ impl Condvar {
144142
.and_then(|t| t.to_timespec_capped())
145143
.unwrap_or(TIMESPEC_MAX_CAPPED);
146144

147-
let r = libc::pthread_cond_timedwait(raw(self), mutex, &timeout);
145+
let r = libc::pthread_cond_timedwait(self.get(), mutex, &timeout);
148146
assert!(r == libc::ETIMEDOUT || r == 0);
149147
r == 0
150148
}
@@ -162,7 +160,7 @@ impl Condvar {
162160
use crate::sys::time::SystemTime;
163161
use crate::time::Instant;
164162

165-
let mutex = mutex::raw(mutex);
163+
let mutex = mutex.get_assert_locked();
166164
self.verify(mutex);
167165

168166
// OSX implementation of `pthread_cond_timedwait` is buggy
@@ -188,7 +186,7 @@ impl Condvar {
188186
.and_then(|t| t.to_timespec())
189187
.unwrap_or(TIMESPEC_MAX);
190188

191-
let r = libc::pthread_cond_timedwait(raw(self), mutex, &timeout);
189+
let r = libc::pthread_cond_timedwait(self.get(), mutex, &timeout);
192190
debug_assert!(r == libc::ETIMEDOUT || r == 0);
193191

194192
// ETIMEDOUT is not a totally reliable method of determining timeout due

0 commit comments

Comments
 (0)