Skip to content

Commit b8675a2

Browse files
oli-obkfee1-dead
authored andcommitted
HACK: Remove all const trait impls and ~const from libcore/libstd
this makes debugging much easier, as all examples are limited to ui tests
1 parent c59a58c commit b8675a2

Some content is hidden

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

51 files changed

+408
-1117
lines changed

compiler/rustc_ast/src/ptr.rs

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -127,7 +127,7 @@ impl<S: Encoder, T: Encodable<S>> Encodable<S> for P<T> {
127127
}
128128

129129
impl<T> P<[T]> {
130-
pub const fn new() -> P<[T]> {
130+
pub fn new() -> P<[T]> {
131131
P { ptr: Box::default() }
132132
}
133133

library/alloc/src/alloc.rs

Lines changed: 4 additions & 19 deletions
Original file line numberDiff line numberDiff line change
@@ -14,8 +14,6 @@ use core::ptr::{self, NonNull};
1414
#[doc(inline)]
1515
pub use core::alloc::*;
1616

17-
use core::marker::Destruct;
18-
1917
#[cfg(test)]
2018
mod tests;
2119

@@ -325,16 +323,12 @@ unsafe fn exchange_malloc(size: usize, align: usize) -> *mut u8 {
325323

326324
#[cfg_attr(not(test), lang = "box_free")]
327325
#[inline]
328-
#[rustc_const_unstable(feature = "const_box", issue = "92521")]
329326
// This signature has to be the same as `Box`, otherwise an ICE will happen.
330327
// When an additional parameter to `Box` is added (like `A: Allocator`), this has to be added here as
331328
// well.
332329
// For example if `Box` is changed to `struct Box<T: ?Sized, A: Allocator>(Unique<T>, A)`,
333330
// this function has to be changed to `fn box_free<T: ?Sized, A: Allocator>(Unique<T>, A)` as well.
334-
pub(crate) const unsafe fn box_free<T: ?Sized, A: ~const Allocator + ~const Destruct>(
335-
ptr: Unique<T>,
336-
alloc: A,
337-
) {
331+
pub(crate) unsafe fn box_free<T: ?Sized, A: Allocator>(ptr: Unique<T>, alloc: A) {
338332
unsafe {
339333
let size = size_of_val(ptr.as_ref());
340334
let align = min_align_of_val(ptr.as_ref());
@@ -366,21 +360,12 @@ extern "Rust" {
366360
/// [`set_alloc_error_hook`]: ../../std/alloc/fn.set_alloc_error_hook.html
367361
/// [`take_alloc_error_hook`]: ../../std/alloc/fn.take_alloc_error_hook.html
368362
#[stable(feature = "global_alloc", since = "1.28.0")]
369-
#[rustc_const_unstable(feature = "const_alloc_error", issue = "92523")]
370363
#[cfg(all(not(no_global_oom_handling), not(test)))]
371364
#[cold]
372-
pub const fn handle_alloc_error(layout: Layout) -> ! {
373-
const fn ct_error(_: Layout) -> ! {
374-
panic!("allocation failed");
375-
}
376-
377-
fn rt_error(layout: Layout) -> ! {
378-
unsafe {
379-
__rust_alloc_error_handler(layout.size(), layout.align());
380-
}
365+
pub fn handle_alloc_error(layout: Layout) -> ! {
366+
unsafe {
367+
__rust_alloc_error_handler(layout.size(), layout.align());
381368
}
382-
383-
unsafe { core::intrinsics::const_eval_select((layout,), ct_error, rt_error) }
384369
}
385370

386371
// For alloc test `std::alloc::handle_alloc_error` can be used directly.

library/alloc/src/borrow.rs

Lines changed: 2 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -329,10 +329,9 @@ impl<B: ?Sized + ToOwned> Cow<'_, B> {
329329
}
330330

331331
#[stable(feature = "rust1", since = "1.0.0")]
332-
#[rustc_const_unstable(feature = "const_deref", issue = "88955")]
333-
impl<B: ?Sized + ToOwned> const Deref for Cow<'_, B>
332+
impl<B: ?Sized + ToOwned> Deref for Cow<'_, B>
334333
where
335-
B::Owned: ~const Borrow<B>,
334+
B::Owned: Borrow<B>,
336335
{
337336
type Target = B;
338337

library/alloc/src/boxed.rs

Lines changed: 28 additions & 50 deletions
Original file line numberDiff line numberDiff line change
@@ -157,7 +157,7 @@ use core::hash::{Hash, Hasher};
157157
#[cfg(not(no_global_oom_handling))]
158158
use core::iter::FromIterator;
159159
use core::iter::{FusedIterator, Iterator};
160-
use core::marker::{Destruct, Unpin, Unsize};
160+
use core::marker::{Unpin, Unsize};
161161
use core::mem;
162162
use core::ops::{
163163
CoerceUnsized, Deref, DerefMut, DispatchFromDyn, Generator, GeneratorState, Receiver,
@@ -373,12 +373,11 @@ impl<T, A: Allocator> Box<T, A> {
373373
/// ```
374374
#[cfg(not(no_global_oom_handling))]
375375
#[unstable(feature = "allocator_api", issue = "32838")]
376-
#[rustc_const_unstable(feature = "const_box", issue = "92521")]
377376
#[must_use]
378377
#[inline]
379-
pub const fn new_in(x: T, alloc: A) -> Self
378+
pub fn new_in(x: T, alloc: A) -> Self
380379
where
381-
A: ~const Allocator + ~const Destruct,
380+
A: Allocator,
382381
{
383382
let mut boxed = Self::new_uninit_in(alloc);
384383
unsafe {
@@ -403,12 +402,10 @@ impl<T, A: Allocator> Box<T, A> {
403402
/// # Ok::<(), std::alloc::AllocError>(())
404403
/// ```
405404
#[unstable(feature = "allocator_api", issue = "32838")]
406-
#[rustc_const_unstable(feature = "const_box", issue = "92521")]
407405
#[inline]
408-
pub const fn try_new_in(x: T, alloc: A) -> Result<Self, AllocError>
406+
pub fn try_new_in(x: T, alloc: A) -> Result<Self, AllocError>
409407
where
410-
T: ~const Destruct,
411-
A: ~const Allocator + ~const Destruct,
408+
A: Allocator,
412409
{
413410
let mut boxed = Self::try_new_uninit_in(alloc)?;
414411
unsafe {
@@ -438,13 +435,12 @@ impl<T, A: Allocator> Box<T, A> {
438435
/// assert_eq!(*five, 5)
439436
/// ```
440437
#[unstable(feature = "allocator_api", issue = "32838")]
441-
#[rustc_const_unstable(feature = "const_box", issue = "92521")]
442438
#[cfg(not(no_global_oom_handling))]
443439
#[must_use]
444440
// #[unstable(feature = "new_uninit", issue = "63291")]
445-
pub const fn new_uninit_in(alloc: A) -> Box<mem::MaybeUninit<T>, A>
441+
pub fn new_uninit_in(alloc: A) -> Box<mem::MaybeUninit<T>, A>
446442
where
447-
A: ~const Allocator + ~const Destruct,
443+
A: Allocator,
448444
{
449445
let layout = Layout::new::<mem::MaybeUninit<T>>();
450446
// NOTE: Prefer match over unwrap_or_else since closure sometimes not inlineable.
@@ -479,10 +475,9 @@ impl<T, A: Allocator> Box<T, A> {
479475
/// ```
480476
#[unstable(feature = "allocator_api", issue = "32838")]
481477
// #[unstable(feature = "new_uninit", issue = "63291")]
482-
#[rustc_const_unstable(feature = "const_box", issue = "92521")]
483-
pub const fn try_new_uninit_in(alloc: A) -> Result<Box<mem::MaybeUninit<T>, A>, AllocError>
478+
pub fn try_new_uninit_in(alloc: A) -> Result<Box<mem::MaybeUninit<T>, A>, AllocError>
484479
where
485-
A: ~const Allocator + ~const Destruct,
480+
A: Allocator,
486481
{
487482
let layout = Layout::new::<mem::MaybeUninit<T>>();
488483
let ptr = alloc.allocate(layout)?.cast();
@@ -510,13 +505,12 @@ impl<T, A: Allocator> Box<T, A> {
510505
///
511506
/// [zeroed]: mem::MaybeUninit::zeroed
512507
#[unstable(feature = "allocator_api", issue = "32838")]
513-
#[rustc_const_unstable(feature = "const_box", issue = "92521")]
514508
#[cfg(not(no_global_oom_handling))]
515509
// #[unstable(feature = "new_uninit", issue = "63291")]
516510
#[must_use]
517-
pub const fn new_zeroed_in(alloc: A) -> Box<mem::MaybeUninit<T>, A>
511+
pub fn new_zeroed_in(alloc: A) -> Box<mem::MaybeUninit<T>, A>
518512
where
519-
A: ~const Allocator + ~const Destruct,
513+
A: Allocator,
520514
{
521515
let layout = Layout::new::<mem::MaybeUninit<T>>();
522516
// NOTE: Prefer match over unwrap_or_else since closure sometimes not inlineable.
@@ -551,10 +545,9 @@ impl<T, A: Allocator> Box<T, A> {
551545
/// [zeroed]: mem::MaybeUninit::zeroed
552546
#[unstable(feature = "allocator_api", issue = "32838")]
553547
// #[unstable(feature = "new_uninit", issue = "63291")]
554-
#[rustc_const_unstable(feature = "const_box", issue = "92521")]
555-
pub const fn try_new_zeroed_in(alloc: A) -> Result<Box<mem::MaybeUninit<T>, A>, AllocError>
548+
pub fn try_new_zeroed_in(alloc: A) -> Result<Box<mem::MaybeUninit<T>, A>, AllocError>
556549
where
557-
A: ~const Allocator + ~const Destruct,
550+
A: Allocator,
558551
{
559552
let layout = Layout::new::<mem::MaybeUninit<T>>();
560553
let ptr = alloc.allocate_zeroed(layout)?.cast();
@@ -570,12 +563,11 @@ impl<T, A: Allocator> Box<T, A> {
570563
/// construct a (pinned) `Box` in a different way than with [`Box::new_in`].
571564
#[cfg(not(no_global_oom_handling))]
572565
#[unstable(feature = "allocator_api", issue = "32838")]
573-
#[rustc_const_unstable(feature = "const_box", issue = "92521")]
574566
#[must_use]
575567
#[inline(always)]
576-
pub const fn pin_in(x: T, alloc: A) -> Pin<Self>
568+
pub fn pin_in(x: T, alloc: A) -> Pin<Self>
577569
where
578-
A: 'static + ~const Allocator + ~const Destruct,
570+
A: 'static + Allocator,
579571
{
580572
Self::into_pin(Self::new_in(x, alloc))
581573
}
@@ -584,8 +576,7 @@ impl<T, A: Allocator> Box<T, A> {
584576
///
585577
/// This conversion does not allocate on the heap and happens in place.
586578
#[unstable(feature = "box_into_boxed_slice", issue = "71582")]
587-
#[rustc_const_unstable(feature = "const_box", issue = "92521")]
588-
pub const fn into_boxed_slice(boxed: Self) -> Box<[T], A> {
579+
pub fn into_boxed_slice(boxed: Self) -> Box<[T], A> {
589580
let (raw, alloc) = Box::into_raw_with_allocator(boxed);
590581
unsafe { Box::from_raw_in(raw as *mut [T; 1], alloc) }
591582
}
@@ -602,12 +593,8 @@ impl<T, A: Allocator> Box<T, A> {
602593
/// assert_eq!(Box::into_inner(c), 5);
603594
/// ```
604595
#[unstable(feature = "box_into_inner", issue = "80437")]
605-
#[rustc_const_unstable(feature = "const_box", issue = "92521")]
606596
#[inline]
607-
pub const fn into_inner(boxed: Self) -> T
608-
where
609-
Self: ~const Destruct,
610-
{
597+
pub fn into_inner(boxed: Self) -> T {
611598
*boxed
612599
}
613600
}
@@ -821,9 +808,8 @@ impl<T, A: Allocator> Box<mem::MaybeUninit<T>, A> {
821808
/// assert_eq!(*five, 5)
822809
/// ```
823810
#[unstable(feature = "new_uninit", issue = "63291")]
824-
#[rustc_const_unstable(feature = "const_box", issue = "92521")]
825811
#[inline]
826-
pub const unsafe fn assume_init(self) -> Box<T, A> {
812+
pub unsafe fn assume_init(self) -> Box<T, A> {
827813
let (raw, alloc) = Box::into_raw_with_allocator(self);
828814
unsafe { Box::from_raw_in(raw as *mut T, alloc) }
829815
}
@@ -856,9 +842,8 @@ impl<T, A: Allocator> Box<mem::MaybeUninit<T>, A> {
856842
/// }
857843
/// ```
858844
#[unstable(feature = "new_uninit", issue = "63291")]
859-
#[rustc_const_unstable(feature = "const_box", issue = "92521")]
860845
#[inline]
861-
pub const fn write(mut boxed: Self, value: T) -> Box<T, A> {
846+
pub fn write(mut boxed: Self, value: T) -> Box<T, A> {
862847
unsafe {
863848
(*boxed).write(value);
864849
boxed.assume_init()
@@ -1101,9 +1086,8 @@ impl<T: ?Sized, A: Allocator> Box<T, A> {
11011086
///
11021087
/// [memory layout]: self#memory-layout
11031088
#[unstable(feature = "allocator_api", issue = "32838")]
1104-
#[rustc_const_unstable(feature = "const_box", issue = "92521")]
11051089
#[inline]
1106-
pub const fn into_raw_with_allocator(b: Self) -> (*mut T, A) {
1090+
pub fn into_raw_with_allocator(b: Self) -> (*mut T, A) {
11071091
let (leaked, alloc) = Box::into_unique(b);
11081092
(leaked.as_ptr(), alloc)
11091093
}
@@ -1113,10 +1097,9 @@ impl<T: ?Sized, A: Allocator> Box<T, A> {
11131097
issue = "none",
11141098
reason = "use `Box::leak(b).into()` or `Unique::from(Box::leak(b))` instead"
11151099
)]
1116-
#[rustc_const_unstable(feature = "const_box", issue = "92521")]
11171100
#[inline]
11181101
#[doc(hidden)]
1119-
pub const fn into_unique(b: Self) -> (Unique<T>, A) {
1102+
pub fn into_unique(b: Self) -> (Unique<T>, A) {
11201103
// Box is recognized as a "unique pointer" by Stacked Borrows, but internally it is a
11211104
// raw pointer for the type system. Turning it directly into a raw pointer would not be
11221105
// recognized as "releasing" the unique pointer to permit aliased raw accesses,
@@ -1174,9 +1157,8 @@ impl<T: ?Sized, A: Allocator> Box<T, A> {
11741157
/// assert_eq!(*static_ref, [4, 2, 3]);
11751158
/// ```
11761159
#[stable(feature = "box_leak", since = "1.26.0")]
1177-
#[rustc_const_unstable(feature = "const_box", issue = "92521")]
11781160
#[inline]
1179-
pub const fn leak<'a>(b: Self) -> &'a mut T
1161+
pub fn leak<'a>(b: Self) -> &'a mut T
11801162
where
11811163
A: 'a,
11821164
{
@@ -1246,7 +1228,7 @@ impl<T: Default> Default for Box<T> {
12461228
#[cfg(not(no_global_oom_handling))]
12471229
#[stable(feature = "rust1", since = "1.0.0")]
12481230
#[rustc_const_unstable(feature = "const_default_impls", issue = "87864")]
1249-
impl<T> const Default for Box<[T]> {
1231+
impl<T> Default for Box<[T]> {
12501232
fn default() -> Self {
12511233
let ptr: Unique<[T]> = Unique::<[T; 0]>::dangling();
12521234
Box(ptr, Global)
@@ -1256,7 +1238,7 @@ impl<T> const Default for Box<[T]> {
12561238
#[cfg(not(no_global_oom_handling))]
12571239
#[stable(feature = "default_box_extra", since = "1.17.0")]
12581240
#[rustc_const_unstable(feature = "const_default_impls", issue = "87864")]
1259-
impl const Default for Box<str> {
1241+
impl Default for Box<str> {
12601242
fn default() -> Self {
12611243
// SAFETY: This is the same as `Unique::cast<U>` but with an unsized `U = str`.
12621244
let ptr: Unique<str> = unsafe {
@@ -1452,8 +1434,7 @@ impl<T> From<T> for Box<T> {
14521434
}
14531435

14541436
#[stable(feature = "pin", since = "1.33.0")]
1455-
#[rustc_const_unstable(feature = "const_box", issue = "92521")]
1456-
impl<T: ?Sized, A: Allocator> const From<Box<T, A>> for Pin<Box<T, A>>
1437+
impl<T: ?Sized, A: Allocator> From<Box<T, A>> for Pin<Box<T, A>>
14571438
where
14581439
A: 'static,
14591440
{
@@ -1841,8 +1822,7 @@ impl<T: ?Sized, A: Allocator> fmt::Pointer for Box<T, A> {
18411822
}
18421823

18431824
#[stable(feature = "rust1", since = "1.0.0")]
1844-
#[rustc_const_unstable(feature = "const_box", issue = "92521")]
1845-
impl<T: ?Sized, A: Allocator> const Deref for Box<T, A> {
1825+
impl<T: ?Sized, A: Allocator> Deref for Box<T, A> {
18461826
type Target = T;
18471827

18481828
fn deref(&self) -> &T {
@@ -1851,8 +1831,7 @@ impl<T: ?Sized, A: Allocator> const Deref for Box<T, A> {
18511831
}
18521832

18531833
#[stable(feature = "rust1", since = "1.0.0")]
1854-
#[rustc_const_unstable(feature = "const_box", issue = "92521")]
1855-
impl<T: ?Sized, A: Allocator> const DerefMut for Box<T, A> {
1834+
impl<T: ?Sized, A: Allocator> DerefMut for Box<T, A> {
18561835
fn deref_mut(&mut self) -> &mut T {
18571836
&mut **self
18581837
}
@@ -2031,8 +2010,7 @@ impl<T: ?Sized, A: Allocator> AsMut<T> for Box<T, A> {
20312010
* could have a method to project a Pin<T> from it.
20322011
*/
20332012
#[stable(feature = "pin", since = "1.33.0")]
2034-
#[rustc_const_unstable(feature = "const_box", issue = "92521")]
2035-
impl<T: ?Sized, A: Allocator> const Unpin for Box<T, A> where A: 'static {}
2013+
impl<T: ?Sized, A: Allocator> Unpin for Box<T, A> where A: 'static {}
20362014

20372015
#[unstable(feature = "generator_trait", issue = "43122")]
20382016
impl<G: ?Sized + Generator<R> + Unpin, R, A: Allocator> Generator<R> for Box<G, A>

library/alloc/src/lib.rs

Lines changed: 0 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -95,11 +95,9 @@
9595
#![feature(assert_matches)]
9696
#![feature(async_iterator)]
9797
#![feature(coerce_unsized)]
98-
#![cfg_attr(not(no_global_oom_handling), feature(const_alloc_error))]
9998
#![feature(const_box)]
10099
#![cfg_attr(not(no_global_oom_handling), feature(const_btree_new))]
101100
#![feature(const_cow_is_borrowed)]
102-
#![feature(const_convert)]
103101
#![feature(const_size_of_val)]
104102
#![feature(const_align_of_val)]
105103
#![feature(const_ptr_read)]
@@ -109,7 +107,6 @@
109107
#![feature(core_c_str)]
110108
#![feature(core_intrinsics)]
111109
#![feature(core_ffi_c)]
112-
#![feature(const_eval_select)]
113110
#![feature(const_pin)]
114111
#![feature(cstr_from_bytes_until_nul)]
115112
#![feature(dispatch_from_dyn)]
@@ -150,7 +147,6 @@
150147
#![feature(allow_internal_unstable)]
151148
#![feature(associated_type_bounds)]
152149
#![feature(cfg_sanitize)]
153-
#![feature(const_deref)]
154150
#![feature(const_mut_refs)]
155151
#![feature(const_ptr_write)]
156152
#![feature(const_precise_live_drops)]

library/alloc/src/string.rs

Lines changed: 1 addition & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -2212,8 +2212,7 @@ impl_eq! { Cow<'a, str>, &'b str }
22122212
impl_eq! { Cow<'a, str>, String }
22132213

22142214
#[stable(feature = "rust1", since = "1.0.0")]
2215-
#[rustc_const_unstable(feature = "const_default_impls", issue = "87864")]
2216-
impl const Default for String {
2215+
impl Default for String {
22172216
/// Creates an empty `String`.
22182217
#[inline]
22192218
fn default() -> String {

library/alloc/src/vec/mod.rs

Lines changed: 1 addition & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -2924,8 +2924,7 @@ unsafe impl<#[may_dangle] T, A: Allocator> Drop for Vec<T, A> {
29242924
}
29252925

29262926
#[stable(feature = "rust1", since = "1.0.0")]
2927-
#[rustc_const_unstable(feature = "const_default_impls", issue = "87864")]
2928-
impl<T> const Default for Vec<T> {
2927+
impl<T> Default for Vec<T> {
29292928
/// Creates an empty `Vec<T>`.
29302929
fn default() -> Vec<T> {
29312930
Vec::new()

0 commit comments

Comments
 (0)