Skip to content

Commit e34ad76

Browse files
Remove ~const from alloc
1 parent cbc064b commit e34ad76

File tree

5 files changed

+19
-54
lines changed

5 files changed

+19
-54
lines changed

library/alloc/src/alloc.rs

+1-7
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

@@ -331,16 +329,12 @@ unsafe fn exchange_malloc(size: usize, align: usize) -> *mut u8 {
331329

332330
#[cfg_attr(not(test), lang = "box_free")]
333331
#[inline]
334-
#[rustc_const_unstable(feature = "const_box", issue = "92521")]
335332
// This signature has to be the same as `Box`, otherwise an ICE will happen.
336333
// When an additional parameter to `Box` is added (like `A: Allocator`), this has to be added here as
337334
// well.
338335
// For example if `Box` is changed to `struct Box<T: ?Sized, A: Allocator>(Unique<T>, A)`,
339336
// this function has to be changed to `fn box_free<T: ?Sized, A: Allocator>(Unique<T>, A)` as well.
340-
pub(crate) const unsafe fn box_free<T: ?Sized, A: ~const Allocator + ~const Destruct>(
341-
ptr: Unique<T>,
342-
alloc: A,
343-
) {
337+
pub(crate) unsafe fn box_free<T: ?Sized, A: Allocator>(ptr: Unique<T>, alloc: A) {
344338
unsafe {
345339
let size = size_of_val(ptr.as_ref());
346340
let align = min_align_of_val(ptr.as_ref());

library/alloc/src/borrow.rs

+2-3
Original file line numberDiff line numberDiff line change
@@ -328,10 +328,9 @@ impl<B: ?Sized + ToOwned> Cow<'_, B> {
328328
}
329329

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

library/alloc/src/boxed.rs

+16-28
Original file line numberDiff line numberDiff line change
@@ -159,7 +159,7 @@ use core::hash::{Hash, Hasher};
159159
use core::iter::FromIterator;
160160
use core::iter::{FusedIterator, Iterator};
161161
use core::marker::Tuple;
162-
use core::marker::{Destruct, Unpin, Unsize};
162+
use core::marker::{Unpin, Unsize};
163163
use core::mem;
164164
use core::ops::{
165165
CoerceUnsized, Deref, DerefMut, DispatchFromDyn, Generator, GeneratorState, Receiver,
@@ -376,12 +376,11 @@ impl<T, A: Allocator> Box<T, A> {
376376
/// ```
377377
#[cfg(not(no_global_oom_handling))]
378378
#[unstable(feature = "allocator_api", issue = "32838")]
379-
#[rustc_const_unstable(feature = "const_box", issue = "92521")]
380379
#[must_use]
381380
#[inline]
382-
pub const fn new_in(x: T, alloc: A) -> Self
381+
pub fn new_in(x: T, alloc: A) -> Self
383382
where
384-
A: ~const Allocator + ~const Destruct,
383+
A: Allocator,
385384
{
386385
let mut boxed = Self::new_uninit_in(alloc);
387386
unsafe {
@@ -406,12 +405,10 @@ impl<T, A: Allocator> Box<T, A> {
406405
/// # Ok::<(), std::alloc::AllocError>(())
407406
/// ```
408407
#[unstable(feature = "allocator_api", issue = "32838")]
409-
#[rustc_const_unstable(feature = "const_box", issue = "92521")]
410408
#[inline]
411-
pub const fn try_new_in(x: T, alloc: A) -> Result<Self, AllocError>
409+
pub fn try_new_in(x: T, alloc: A) -> Result<Self, AllocError>
412410
where
413-
T: ~const Destruct,
414-
A: ~const Allocator + ~const Destruct,
411+
A: Allocator,
415412
{
416413
let mut boxed = Self::try_new_uninit_in(alloc)?;
417414
unsafe {
@@ -441,13 +438,12 @@ impl<T, A: Allocator> Box<T, A> {
441438
/// assert_eq!(*five, 5)
442439
/// ```
443440
#[unstable(feature = "allocator_api", issue = "32838")]
444-
#[rustc_const_unstable(feature = "const_box", issue = "92521")]
445441
#[cfg(not(no_global_oom_handling))]
446442
#[must_use]
447443
// #[unstable(feature = "new_uninit", issue = "63291")]
448-
pub const fn new_uninit_in(alloc: A) -> Box<mem::MaybeUninit<T>, A>
444+
pub fn new_uninit_in(alloc: A) -> Box<mem::MaybeUninit<T>, A>
449445
where
450-
A: ~const Allocator + ~const Destruct,
446+
A: Allocator,
451447
{
452448
let layout = Layout::new::<mem::MaybeUninit<T>>();
453449
// NOTE: Prefer match over unwrap_or_else since closure sometimes not inlineable.
@@ -482,10 +478,9 @@ impl<T, A: Allocator> Box<T, A> {
482478
/// ```
483479
#[unstable(feature = "allocator_api", issue = "32838")]
484480
// #[unstable(feature = "new_uninit", issue = "63291")]
485-
#[rustc_const_unstable(feature = "const_box", issue = "92521")]
486-
pub const fn try_new_uninit_in(alloc: A) -> Result<Box<mem::MaybeUninit<T>, A>, AllocError>
481+
pub fn try_new_uninit_in(alloc: A) -> Result<Box<mem::MaybeUninit<T>, A>, AllocError>
487482
where
488-
A: ~const Allocator + ~const Destruct,
483+
A: Allocator,
489484
{
490485
let layout = Layout::new::<mem::MaybeUninit<T>>();
491486
let ptr = alloc.allocate(layout)?.cast();
@@ -513,13 +508,12 @@ impl<T, A: Allocator> Box<T, A> {
513508
///
514509
/// [zeroed]: mem::MaybeUninit::zeroed
515510
#[unstable(feature = "allocator_api", issue = "32838")]
516-
#[rustc_const_unstable(feature = "const_box", issue = "92521")]
517511
#[cfg(not(no_global_oom_handling))]
518512
// #[unstable(feature = "new_uninit", issue = "63291")]
519513
#[must_use]
520-
pub const fn new_zeroed_in(alloc: A) -> Box<mem::MaybeUninit<T>, A>
514+
pub fn new_zeroed_in(alloc: A) -> Box<mem::MaybeUninit<T>, A>
521515
where
522-
A: ~const Allocator + ~const Destruct,
516+
A: Allocator,
523517
{
524518
let layout = Layout::new::<mem::MaybeUninit<T>>();
525519
// NOTE: Prefer match over unwrap_or_else since closure sometimes not inlineable.
@@ -554,10 +548,9 @@ impl<T, A: Allocator> Box<T, A> {
554548
/// [zeroed]: mem::MaybeUninit::zeroed
555549
#[unstable(feature = "allocator_api", issue = "32838")]
556550
// #[unstable(feature = "new_uninit", issue = "63291")]
557-
#[rustc_const_unstable(feature = "const_box", issue = "92521")]
558-
pub const fn try_new_zeroed_in(alloc: A) -> Result<Box<mem::MaybeUninit<T>, A>, AllocError>
551+
pub fn try_new_zeroed_in(alloc: A) -> Result<Box<mem::MaybeUninit<T>, A>, AllocError>
559552
where
560-
A: ~const Allocator + ~const Destruct,
553+
A: Allocator,
561554
{
562555
let layout = Layout::new::<mem::MaybeUninit<T>>();
563556
let ptr = alloc.allocate_zeroed(layout)?.cast();
@@ -573,12 +566,11 @@ impl<T, A: Allocator> Box<T, A> {
573566
/// construct a (pinned) `Box` in a different way than with [`Box::new_in`].
574567
#[cfg(not(no_global_oom_handling))]
575568
#[unstable(feature = "allocator_api", issue = "32838")]
576-
#[rustc_const_unstable(feature = "const_box", issue = "92521")]
577569
#[must_use]
578570
#[inline(always)]
579-
pub const fn pin_in(x: T, alloc: A) -> Pin<Self>
571+
pub fn pin_in(x: T, alloc: A) -> Pin<Self>
580572
where
581-
A: 'static + ~const Allocator + ~const Destruct,
573+
A: 'static + Allocator,
582574
{
583575
Self::into_pin(Self::new_in(x, alloc))
584576
}
@@ -605,12 +597,8 @@ impl<T, A: Allocator> Box<T, A> {
605597
/// assert_eq!(Box::into_inner(c), 5);
606598
/// ```
607599
#[unstable(feature = "box_into_inner", issue = "80437")]
608-
#[rustc_const_unstable(feature = "const_box", issue = "92521")]
609600
#[inline]
610-
pub const fn into_inner(boxed: Self) -> T
611-
where
612-
Self: ~const Destruct,
613-
{
601+
pub fn into_inner(boxed: Self) -> T {
614602
*boxed
615603
}
616604
}

library/alloc/tests/boxed.rs

-15
Original file line numberDiff line numberDiff line change
@@ -179,18 +179,3 @@ unsafe impl const Allocator for ConstAllocator {
179179
self
180180
}
181181
}
182-
183-
#[test]
184-
fn const_box() {
185-
const VALUE: u32 = {
186-
let mut boxed = Box::new_in(1u32, ConstAllocator);
187-
assert!(*boxed == 1);
188-
189-
*boxed = 42;
190-
assert!(*boxed == 42);
191-
192-
*Box::leak(boxed)
193-
};
194-
195-
assert!(VALUE == 42);
196-
}

library/alloc/tests/lib.rs

-1
Original file line numberDiff line numberDiff line change
@@ -3,7 +3,6 @@
33
#![feature(assert_matches)]
44
#![feature(btree_drain_filter)]
55
#![feature(cow_is_borrowed)]
6-
#![feature(const_box)]
76
#![feature(const_convert)]
87
#![feature(const_cow_is_borrowed)]
98
#![feature(const_heap)]

0 commit comments

Comments
 (0)