Skip to content

Commit 76dbe29

Browse files
committed
rm const traits in libcore
1 parent 2a71115 commit 76dbe29

Some content is hidden

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

58 files changed

+475
-868
lines changed

Diff for: library/alloc/src/boxed.rs

+5-10
Original file line numberDiff line numberDiff line change
@@ -1234,8 +1234,7 @@ impl<T: Default> Default for Box<T> {
12341234

12351235
#[cfg(not(no_global_oom_handling))]
12361236
#[stable(feature = "rust1", since = "1.0.0")]
1237-
#[rustc_const_unstable(feature = "const_default_impls", issue = "87864")]
1238-
impl<T> const Default for Box<[T]> {
1237+
impl<T> Default for Box<[T]> {
12391238
#[inline]
12401239
fn default() -> Self {
12411240
let ptr: Unique<[T]> = Unique::<[T; 0]>::dangling();
@@ -1245,8 +1244,7 @@ impl<T> const Default for Box<[T]> {
12451244

12461245
#[cfg(not(no_global_oom_handling))]
12471246
#[stable(feature = "default_box_extra", since = "1.17.0")]
1248-
#[rustc_const_unstable(feature = "const_default_impls", issue = "87864")]
1249-
impl const Default for Box<str> {
1247+
impl Default for Box<str> {
12501248
#[inline]
12511249
fn default() -> Self {
12521250
// SAFETY: This is the same as `Unique::cast<U>` but with an unsized `U = str`.
@@ -1443,8 +1441,7 @@ impl<T> From<T> for Box<T> {
14431441
}
14441442

14451443
#[stable(feature = "pin", since = "1.33.0")]
1446-
#[rustc_const_unstable(feature = "const_box", issue = "92521")]
1447-
impl<T: ?Sized, A: Allocator> const From<Box<T, A>> for Pin<Box<T, A>>
1444+
impl<T: ?Sized, A: Allocator> From<Box<T, A>> for Pin<Box<T, A>>
14481445
where
14491446
A: 'static,
14501447
{
@@ -1880,8 +1877,7 @@ impl<T: ?Sized, A: Allocator> fmt::Pointer for Box<T, A> {
18801877
}
18811878

18821879
#[stable(feature = "rust1", since = "1.0.0")]
1883-
#[rustc_const_unstable(feature = "const_box", issue = "92521")]
1884-
impl<T: ?Sized, A: Allocator> const Deref for Box<T, A> {
1880+
impl<T: ?Sized, A: Allocator> Deref for Box<T, A> {
18851881
type Target = T;
18861882

18871883
fn deref(&self) -> &T {
@@ -1890,8 +1886,7 @@ impl<T: ?Sized, A: Allocator> const Deref for Box<T, A> {
18901886
}
18911887

18921888
#[stable(feature = "rust1", since = "1.0.0")]
1893-
#[rustc_const_unstable(feature = "const_box", issue = "92521")]
1894-
impl<T: ?Sized, A: Allocator> const DerefMut for Box<T, A> {
1889+
impl<T: ?Sized, A: Allocator> DerefMut for Box<T, A> {
18951890
fn deref_mut(&mut self) -> &mut T {
18961891
&mut **self
18971892
}

Diff for: library/alloc/src/string.rs

+1-2
Original file line numberDiff line numberDiff line change
@@ -2247,8 +2247,7 @@ impl_eq! { Cow<'a, str>, &'b str }
22472247
impl_eq! { Cow<'a, str>, String }
22482248

22492249
#[stable(feature = "rust1", since = "1.0.0")]
2250-
#[rustc_const_unstable(feature = "const_default_impls", issue = "87864")]
2251-
impl const Default for String {
2250+
impl Default for String {
22522251
/// Creates an empty `String`.
22532252
#[inline]
22542253
fn default() -> String {

Diff for: library/alloc/src/vec/mod.rs

+1-2
Original file line numberDiff line numberDiff line change
@@ -3022,8 +3022,7 @@ unsafe impl<#[may_dangle] T, A: Allocator> Drop for Vec<T, A> {
30223022
}
30233023

30243024
#[stable(feature = "rust1", since = "1.0.0")]
3025-
#[rustc_const_unstable(feature = "const_default_impls", issue = "87864")]
3026-
impl<T> const Default for Vec<T> {
3025+
impl<T> Default for Vec<T> {
30273026
/// Creates an empty `Vec<T>`.
30283027
///
30293028
/// The vector will not allocate until elements are pushed onto it.

Diff for: library/alloc/tests/boxed.rs

+1-1
Original file line numberDiff line numberDiff line change
@@ -61,7 +61,7 @@ fn box_deref_lval() {
6161

6262
pub struct ConstAllocator;
6363

64-
unsafe impl const Allocator for ConstAllocator {
64+
unsafe impl Allocator for ConstAllocator {
6565
fn allocate(&self, layout: Layout) -> Result<NonNull<[u8]>, AllocError> {
6666
match layout.size() {
6767
0 => Ok(NonNull::slice_from_raw_parts(layout.dangling(), 0)),

Diff for: library/core/src/alloc/mod.rs

-1
Original file line numberDiff line numberDiff line change
@@ -105,7 +105,6 @@ impl fmt::Display for AllocError {
105105
///
106106
/// [*currently allocated*]: #currently-allocated-memory
107107
#[unstable(feature = "allocator_api", issue = "32838")]
108-
#[const_trait]
109108
pub unsafe trait Allocator {
110109
/// Attempts to allocate a block of memory.
111110
///

Diff for: library/core/src/any.rs

+1-2
Original file line numberDiff line numberDiff line change
@@ -662,8 +662,7 @@ impl dyn Any + Send + Sync {
662662
/// While `TypeId` implements `Hash`, `PartialOrd`, and `Ord`, it is worth
663663
/// noting that the hashes and ordering will vary between Rust releases. Beware
664664
/// of relying on them inside of your code!
665-
#[derive(Clone, Copy, Debug, Hash, Eq)]
666-
#[derive_const(PartialEq, PartialOrd, Ord)]
665+
#[derive(Clone, Copy, Debug, Hash, PartialEq, Eq, PartialOrd, Ord)]
667666
#[stable(feature = "rust1", since = "1.0.0")]
668667
pub struct TypeId {
669668
t: u64,

Diff for: library/core/src/array/mod.rs

+9-16
Original file line numberDiff line numberDiff line change
@@ -148,8 +148,7 @@ impl Error for TryFromSliceError {
148148
}
149149

150150
#[stable(feature = "try_from_slice_error", since = "1.36.0")]
151-
#[rustc_const_unstable(feature = "const_convert", issue = "88674")]
152-
impl const From<Infallible> for TryFromSliceError {
151+
impl From<Infallible> for TryFromSliceError {
153152
fn from(x: Infallible) -> TryFromSliceError {
154153
match x {}
155154
}
@@ -172,16 +171,14 @@ impl<T, const N: usize> AsMut<[T]> for [T; N] {
172171
}
173172

174173
#[stable(feature = "array_borrow", since = "1.4.0")]
175-
#[rustc_const_unstable(feature = "const_borrow", issue = "91522")]
176-
impl<T, const N: usize> const Borrow<[T]> for [T; N] {
174+
impl<T, const N: usize> Borrow<[T]> for [T; N] {
177175
fn borrow(&self) -> &[T] {
178176
self
179177
}
180178
}
181179

182180
#[stable(feature = "array_borrow", since = "1.4.0")]
183-
#[rustc_const_unstable(feature = "const_borrow", issue = "91522")]
184-
impl<T, const N: usize> const BorrowMut<[T]> for [T; N] {
181+
impl<T, const N: usize> BorrowMut<[T]> for [T; N] {
185182
fn borrow_mut(&mut self) -> &mut [T] {
186183
self
187184
}
@@ -336,10 +333,9 @@ impl<'a, T, const N: usize> IntoIterator for &'a mut [T; N] {
336333
}
337334

338335
#[stable(feature = "index_trait_on_arrays", since = "1.50.0")]
339-
#[rustc_const_unstable(feature = "const_slice_index", issue = "none")]
340-
impl<T, I, const N: usize> const Index<I> for [T; N]
336+
impl<T, I, const N: usize> Index<I> for [T; N]
341337
where
342-
[T]: ~const Index<I>,
338+
[T]: Index<I>,
343339
{
344340
type Output = <[T] as Index<I>>::Output;
345341

@@ -350,10 +346,9 @@ where
350346
}
351347

352348
#[stable(feature = "index_trait_on_arrays", since = "1.50.0")]
353-
#[rustc_const_unstable(feature = "const_slice_index", issue = "none")]
354-
impl<T, I, const N: usize> const IndexMut<I> for [T; N]
349+
impl<T, I, const N: usize> IndexMut<I> for [T; N]
355350
where
356-
[T]: ~const IndexMut<I>,
351+
[T]: IndexMut<I>,
357352
{
358353
#[inline]
359354
fn index_mut(&mut self, index: I) -> &mut Self::Output {
@@ -435,8 +430,7 @@ impl<T: Copy> SpecArrayClone for T {
435430
macro_rules! array_impl_default {
436431
{$n:expr, $t:ident $($ts:ident)*} => {
437432
#[stable(since = "1.4.0", feature = "array_default")]
438-
#[rustc_const_unstable(feature = "const_default_impls", issue = "87864")]
439-
impl<T> const Default for [T; $n] where T: ~const Default {
433+
impl<T> Default for [T; $n] where T: Default {
440434
fn default() -> [T; $n] {
441435
[$t::default(), $($ts::default()),*]
442436
}
@@ -445,8 +439,7 @@ macro_rules! array_impl_default {
445439
};
446440
{$n:expr,} => {
447441
#[stable(since = "1.4.0", feature = "array_default")]
448-
#[rustc_const_unstable(feature = "const_default_impls", issue = "87864")]
449-
impl<T> const Default for [T; $n] {
442+
impl<T> Default for [T; $n] {
450443
fn default() -> [T; $n] { [] }
451444
}
452445
};

Diff for: library/core/src/bool.rs

+2-11
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,5 @@
11
//! impl bool {}
22
3-
use crate::marker::Destruct;
4-
53
impl bool {
64
/// Returns `Some(t)` if the `bool` is [`true`](../std/keyword.true.html),
75
/// or `None` otherwise.
@@ -31,11 +29,8 @@ impl bool {
3129
/// assert_eq!(a, 2);
3230
/// ```
3331
#[stable(feature = "bool_to_option", since = "1.62.0")]
34-
#[rustc_const_unstable(feature = "const_bool_to_option", issue = "91917")]
3532
#[inline]
36-
pub const fn then_some<T>(self, t: T) -> Option<T>
37-
where
38-
T: ~const Destruct,
33+
pub fn then_some<T>(self, t: T) -> Option<T>
3934
{
4035
if self { Some(t) } else { None }
4136
}
@@ -61,12 +56,8 @@ impl bool {
6156
/// assert_eq!(a, 1);
6257
/// ```
6358
#[stable(feature = "lazy_bool_to_option", since = "1.50.0")]
64-
#[rustc_const_unstable(feature = "const_bool_to_option", issue = "91917")]
6559
#[inline]
66-
pub const fn then<T, F>(self, f: F) -> Option<T>
67-
where
68-
F: ~const FnOnce() -> T,
69-
F: ~const Destruct,
60+
pub fn then<T, F: FnOnce() -> T>(self, f: F) -> Option<T>
7061
{
7162
if self { Some(f()) } else { None }
7263
}

Diff for: library/core/src/borrow.rs

+5-12
Original file line numberDiff line numberDiff line change
@@ -154,7 +154,6 @@
154154
/// [`String`]: ../../std/string/struct.String.html
155155
#[stable(feature = "rust1", since = "1.0.0")]
156156
#[rustc_diagnostic_item = "Borrow"]
157-
#[const_trait]
158157
pub trait Borrow<Borrowed: ?Sized> {
159158
/// Immutably borrows from an owned value.
160159
///
@@ -185,7 +184,6 @@ pub trait Borrow<Borrowed: ?Sized> {
185184
/// an underlying type by providing a mutable reference. See [`Borrow<T>`]
186185
/// for more information on borrowing as another type.
187186
#[stable(feature = "rust1", since = "1.0.0")]
188-
#[const_trait]
189187
pub trait BorrowMut<Borrowed: ?Sized>: Borrow<Borrowed> {
190188
/// Mutably borrows from an owned value.
191189
///
@@ -207,41 +205,36 @@ pub trait BorrowMut<Borrowed: ?Sized>: Borrow<Borrowed> {
207205
}
208206

209207
#[stable(feature = "rust1", since = "1.0.0")]
210-
#[rustc_const_unstable(feature = "const_borrow", issue = "91522")]
211-
impl<T: ?Sized> const Borrow<T> for T {
208+
impl<T: ?Sized> Borrow<T> for T {
212209
#[rustc_diagnostic_item = "noop_method_borrow"]
213210
fn borrow(&self) -> &T {
214211
self
215212
}
216213
}
217214

218215
#[stable(feature = "rust1", since = "1.0.0")]
219-
#[rustc_const_unstable(feature = "const_borrow", issue = "91522")]
220-
impl<T: ?Sized> const BorrowMut<T> for T {
216+
impl<T: ?Sized> BorrowMut<T> for T {
221217
fn borrow_mut(&mut self) -> &mut T {
222218
self
223219
}
224220
}
225221

226222
#[stable(feature = "rust1", since = "1.0.0")]
227-
#[rustc_const_unstable(feature = "const_borrow", issue = "91522")]
228-
impl<T: ?Sized> const Borrow<T> for &T {
223+
impl<T: ?Sized> Borrow<T> for &T {
229224
fn borrow(&self) -> &T {
230225
&**self
231226
}
232227
}
233228

234229
#[stable(feature = "rust1", since = "1.0.0")]
235-
#[rustc_const_unstable(feature = "const_borrow", issue = "91522")]
236-
impl<T: ?Sized> const Borrow<T> for &mut T {
230+
impl<T: ?Sized> Borrow<T> for &mut T {
237231
fn borrow(&self) -> &T {
238232
&**self
239233
}
240234
}
241235

242236
#[stable(feature = "rust1", since = "1.0.0")]
243-
#[rustc_const_unstable(feature = "const_borrow", issue = "91522")]
244-
impl<T: ?Sized> const BorrowMut<T> for &mut T {
237+
impl<T: ?Sized> BorrowMut<T> for &mut T {
245238
fn borrow_mut(&mut self) -> &mut T {
246239
&mut **self
247240
}

Diff for: library/core/src/cell.rs

+4-8
Original file line numberDiff line numberDiff line change
@@ -370,8 +370,7 @@ impl<T: Ord + Copy> Ord for Cell<T> {
370370
}
371371

372372
#[stable(feature = "cell_from", since = "1.12.0")]
373-
#[rustc_const_unstable(feature = "const_convert", issue = "88674")]
374-
impl<T> const From<T> for Cell<T> {
373+
impl<T> From<T> for Cell<T> {
375374
/// Creates a new `Cell<T>` containing the given value.
376375
fn from(t: T) -> Cell<T> {
377376
Cell::new(t)
@@ -1318,8 +1317,7 @@ impl<T: ?Sized + Ord> Ord for RefCell<T> {
13181317
}
13191318

13201319
#[stable(feature = "cell_from", since = "1.12.0")]
1321-
#[rustc_const_unstable(feature = "const_convert", issue = "88674")]
1322-
impl<T> const From<T> for RefCell<T> {
1320+
impl<T> From<T> for RefCell<T> {
13231321
/// Creates a new `RefCell<T>` containing the given value.
13241322
fn from(t: T) -> RefCell<T> {
13251323
RefCell::new(t)
@@ -2126,8 +2124,7 @@ impl<T: Default> Default for UnsafeCell<T> {
21262124
}
21272125

21282126
#[stable(feature = "cell_from", since = "1.12.0")]
2129-
#[rustc_const_unstable(feature = "const_convert", issue = "88674")]
2130-
impl<T> const From<T> for UnsafeCell<T> {
2127+
impl<T> From<T> for UnsafeCell<T> {
21312128
/// Creates a new `UnsafeCell<T>` containing the given value.
21322129
fn from(t: T) -> UnsafeCell<T> {
21332130
UnsafeCell::new(t)
@@ -2226,8 +2223,7 @@ impl<T: Default> Default for SyncUnsafeCell<T> {
22262223
}
22272224

22282225
#[unstable(feature = "sync_unsafe_cell", issue = "95439")]
2229-
#[rustc_const_unstable(feature = "const_convert", issue = "88674")]
2230-
impl<T> const From<T> for SyncUnsafeCell<T> {
2226+
impl<T> From<T> for SyncUnsafeCell<T> {
22312227
/// Creates a new `SyncUnsafeCell<T>` containing the given value.
22322228
fn from(t: T) -> SyncUnsafeCell<T> {
22332229
SyncUnsafeCell::new(t)

Diff for: library/core/src/cell/once.rs

+1-2
Original file line numberDiff line numberDiff line change
@@ -284,8 +284,7 @@ impl<T: PartialEq> PartialEq for OnceCell<T> {
284284
impl<T: Eq> Eq for OnceCell<T> {}
285285

286286
#[stable(feature = "once_cell", since = "CURRENT_RUSTC_VERSION")]
287-
#[rustc_const_unstable(feature = "const_convert", issue = "88674")]
288-
impl<T> const From<T> for OnceCell<T> {
287+
impl<T> From<T> for OnceCell<T> {
289288
/// Creates a new `OnceCell<T>` which already contains the given `value`.
290289
#[inline]
291290
fn from(value: T) -> Self {

Diff for: library/core/src/char/convert.rs

+4-8
Original file line numberDiff line numberDiff line change
@@ -27,8 +27,7 @@ pub(super) const unsafe fn from_u32_unchecked(i: u32) -> char {
2727
}
2828

2929
#[stable(feature = "char_convert", since = "1.13.0")]
30-
#[rustc_const_unstable(feature = "const_convert", issue = "88674")]
31-
impl const From<char> for u32 {
30+
impl From<char> for u32 {
3231
/// Converts a [`char`] into a [`u32`].
3332
///
3433
/// # Examples
@@ -47,8 +46,7 @@ impl const From<char> for u32 {
4746
}
4847

4948
#[stable(feature = "more_char_conversions", since = "1.51.0")]
50-
#[rustc_const_unstable(feature = "const_convert", issue = "88674")]
51-
impl const From<char> for u64 {
49+
impl From<char> for u64 {
5250
/// Converts a [`char`] into a [`u64`].
5351
///
5452
/// # Examples
@@ -69,8 +67,7 @@ impl const From<char> for u64 {
6967
}
7068

7169
#[stable(feature = "more_char_conversions", since = "1.51.0")]
72-
#[rustc_const_unstable(feature = "const_convert", issue = "88674")]
73-
impl const From<char> for u128 {
70+
impl From<char> for u128 {
7471
/// Converts a [`char`] into a [`u128`].
7572
///
7673
/// # Examples
@@ -123,8 +120,7 @@ impl TryFrom<char> for u8 {
123120
/// for a superset of Windows-1252 that fills the remaining blanks with corresponding
124121
/// C0 and C1 control codes.
125122
#[stable(feature = "char_convert", since = "1.13.0")]
126-
#[rustc_const_unstable(feature = "const_convert", issue = "88674")]
127-
impl const From<u8> for char {
123+
impl From<u8> for char {
128124
/// Converts a [`u8`] into a [`char`].
129125
///
130126
/// # Examples

0 commit comments

Comments
 (0)