@@ -157,7 +157,7 @@ use core::hash::{Hash, Hasher};
157
157
#[ cfg( not( no_global_oom_handling) ) ]
158
158
use core:: iter:: FromIterator ;
159
159
use core:: iter:: { FusedIterator , Iterator } ;
160
- use core:: marker:: { Destruct , Unpin , Unsize } ;
160
+ use core:: marker:: { Unpin , Unsize } ;
161
161
use core:: mem;
162
162
use core:: ops:: {
163
163
CoerceUnsized , Deref , DerefMut , DispatchFromDyn , Generator , GeneratorState , Receiver ,
@@ -373,12 +373,11 @@ impl<T, A: Allocator> Box<T, A> {
373
373
/// ```
374
374
#[ cfg( not( no_global_oom_handling) ) ]
375
375
#[ unstable( feature = "allocator_api" , issue = "32838" ) ]
376
- #[ rustc_const_unstable( feature = "const_box" , issue = "92521" ) ]
377
376
#[ must_use]
378
377
#[ inline]
379
- pub const fn new_in ( x : T , alloc : A ) -> Self
378
+ pub fn new_in ( x : T , alloc : A ) -> Self
380
379
where
381
- A : ~ const Allocator + ~ const Destruct ,
380
+ A : Allocator ,
382
381
{
383
382
let mut boxed = Self :: new_uninit_in ( alloc) ;
384
383
unsafe {
@@ -403,12 +402,10 @@ impl<T, A: Allocator> Box<T, A> {
403
402
/// # Ok::<(), std::alloc::AllocError>(())
404
403
/// ```
405
404
#[ unstable( feature = "allocator_api" , issue = "32838" ) ]
406
- #[ rustc_const_unstable( feature = "const_box" , issue = "92521" ) ]
407
405
#[ 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 >
409
407
where
410
- T : ~const Destruct ,
411
- A : ~const Allocator + ~const Destruct ,
408
+ A : Allocator ,
412
409
{
413
410
let mut boxed = Self :: try_new_uninit_in ( alloc) ?;
414
411
unsafe {
@@ -438,13 +435,12 @@ impl<T, A: Allocator> Box<T, A> {
438
435
/// assert_eq!(*five, 5)
439
436
/// ```
440
437
#[ unstable( feature = "allocator_api" , issue = "32838" ) ]
441
- #[ rustc_const_unstable( feature = "const_box" , issue = "92521" ) ]
442
438
#[ cfg( not( no_global_oom_handling) ) ]
443
439
#[ must_use]
444
440
// #[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 >
446
442
where
447
- A : ~ const Allocator + ~ const Destruct ,
443
+ A : Allocator ,
448
444
{
449
445
let layout = Layout :: new :: < mem:: MaybeUninit < T > > ( ) ;
450
446
// NOTE: Prefer match over unwrap_or_else since closure sometimes not inlineable.
@@ -479,10 +475,9 @@ impl<T, A: Allocator> Box<T, A> {
479
475
/// ```
480
476
#[ unstable( feature = "allocator_api" , issue = "32838" ) ]
481
477
// #[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 >
484
479
where
485
- A : ~ const Allocator + ~ const Destruct ,
480
+ A : Allocator ,
486
481
{
487
482
let layout = Layout :: new :: < mem:: MaybeUninit < T > > ( ) ;
488
483
let ptr = alloc. allocate ( layout) ?. cast ( ) ;
@@ -510,13 +505,12 @@ impl<T, A: Allocator> Box<T, A> {
510
505
///
511
506
/// [zeroed]: mem::MaybeUninit::zeroed
512
507
#[ unstable( feature = "allocator_api" , issue = "32838" ) ]
513
- #[ rustc_const_unstable( feature = "const_box" , issue = "92521" ) ]
514
508
#[ cfg( not( no_global_oom_handling) ) ]
515
509
// #[unstable(feature = "new_uninit", issue = "63291")]
516
510
#[ 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 >
518
512
where
519
- A : ~ const Allocator + ~ const Destruct ,
513
+ A : Allocator ,
520
514
{
521
515
let layout = Layout :: new :: < mem:: MaybeUninit < T > > ( ) ;
522
516
// NOTE: Prefer match over unwrap_or_else since closure sometimes not inlineable.
@@ -551,10 +545,9 @@ impl<T, A: Allocator> Box<T, A> {
551
545
/// [zeroed]: mem::MaybeUninit::zeroed
552
546
#[ unstable( feature = "allocator_api" , issue = "32838" ) ]
553
547
// #[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 >
556
549
where
557
- A : ~ const Allocator + ~ const Destruct ,
550
+ A : Allocator ,
558
551
{
559
552
let layout = Layout :: new :: < mem:: MaybeUninit < T > > ( ) ;
560
553
let ptr = alloc. allocate_zeroed ( layout) ?. cast ( ) ;
@@ -570,12 +563,11 @@ impl<T, A: Allocator> Box<T, A> {
570
563
/// construct a (pinned) `Box` in a different way than with [`Box::new_in`].
571
564
#[ cfg( not( no_global_oom_handling) ) ]
572
565
#[ unstable( feature = "allocator_api" , issue = "32838" ) ]
573
- #[ rustc_const_unstable( feature = "const_box" , issue = "92521" ) ]
574
566
#[ must_use]
575
567
#[ 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 >
577
569
where
578
- A : ' static + ~ const Allocator + ~ const Destruct ,
570
+ A : ' static + Allocator ,
579
571
{
580
572
Self :: into_pin ( Self :: new_in ( x, alloc) )
581
573
}
@@ -584,8 +576,7 @@ impl<T, A: Allocator> Box<T, A> {
584
576
///
585
577
/// This conversion does not allocate on the heap and happens in place.
586
578
#[ 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 > {
589
580
let ( raw, alloc) = Box :: into_raw_with_allocator ( boxed) ;
590
581
unsafe { Box :: from_raw_in ( raw as * mut [ T ; 1 ] , alloc) }
591
582
}
@@ -602,12 +593,8 @@ impl<T, A: Allocator> Box<T, A> {
602
593
/// assert_eq!(Box::into_inner(c), 5);
603
594
/// ```
604
595
#[ unstable( feature = "box_into_inner" , issue = "80437" ) ]
605
- #[ rustc_const_unstable( feature = "const_box" , issue = "92521" ) ]
606
596
#[ 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 {
611
598
* boxed
612
599
}
613
600
}
@@ -821,9 +808,8 @@ impl<T, A: Allocator> Box<mem::MaybeUninit<T>, A> {
821
808
/// assert_eq!(*five, 5)
822
809
/// ```
823
810
#[ unstable( feature = "new_uninit" , issue = "63291" ) ]
824
- #[ rustc_const_unstable( feature = "const_box" , issue = "92521" ) ]
825
811
#[ inline]
826
- pub const unsafe fn assume_init ( self ) -> Box < T , A > {
812
+ pub unsafe fn assume_init ( self ) -> Box < T , A > {
827
813
let ( raw, alloc) = Box :: into_raw_with_allocator ( self ) ;
828
814
unsafe { Box :: from_raw_in ( raw as * mut T , alloc) }
829
815
}
@@ -856,9 +842,8 @@ impl<T, A: Allocator> Box<mem::MaybeUninit<T>, A> {
856
842
/// }
857
843
/// ```
858
844
#[ unstable( feature = "new_uninit" , issue = "63291" ) ]
859
- #[ rustc_const_unstable( feature = "const_box" , issue = "92521" ) ]
860
845
#[ 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 > {
862
847
unsafe {
863
848
( * boxed) . write ( value) ;
864
849
boxed. assume_init ( )
@@ -1101,9 +1086,8 @@ impl<T: ?Sized, A: Allocator> Box<T, A> {
1101
1086
///
1102
1087
/// [memory layout]: self#memory-layout
1103
1088
#[ unstable( feature = "allocator_api" , issue = "32838" ) ]
1104
- #[ rustc_const_unstable( feature = "const_box" , issue = "92521" ) ]
1105
1089
#[ 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 ) {
1107
1091
let ( leaked, alloc) = Box :: into_unique ( b) ;
1108
1092
( leaked. as_ptr ( ) , alloc)
1109
1093
}
@@ -1113,10 +1097,9 @@ impl<T: ?Sized, A: Allocator> Box<T, A> {
1113
1097
issue = "none" ,
1114
1098
reason = "use `Box::leak(b).into()` or `Unique::from(Box::leak(b))` instead"
1115
1099
) ]
1116
- #[ rustc_const_unstable( feature = "const_box" , issue = "92521" ) ]
1117
1100
#[ inline]
1118
1101
#[ doc( hidden) ]
1119
- pub const fn into_unique ( b : Self ) -> ( Unique < T > , A ) {
1102
+ pub fn into_unique ( b : Self ) -> ( Unique < T > , A ) {
1120
1103
// Box is recognized as a "unique pointer" by Stacked Borrows, but internally it is a
1121
1104
// raw pointer for the type system. Turning it directly into a raw pointer would not be
1122
1105
// recognized as "releasing" the unique pointer to permit aliased raw accesses,
@@ -1174,9 +1157,8 @@ impl<T: ?Sized, A: Allocator> Box<T, A> {
1174
1157
/// assert_eq!(*static_ref, [4, 2, 3]);
1175
1158
/// ```
1176
1159
#[ stable( feature = "box_leak" , since = "1.26.0" ) ]
1177
- #[ rustc_const_unstable( feature = "const_box" , issue = "92521" ) ]
1178
1160
#[ inline]
1179
- pub const fn leak < ' a > ( b : Self ) -> & ' a mut T
1161
+ pub fn leak < ' a > ( b : Self ) -> & ' a mut T
1180
1162
where
1181
1163
A : ' a ,
1182
1164
{
@@ -1246,7 +1228,7 @@ impl<T: Default> Default for Box<T> {
1246
1228
#[ cfg( not( no_global_oom_handling) ) ]
1247
1229
#[ stable( feature = "rust1" , since = "1.0.0" ) ]
1248
1230
#[ rustc_const_unstable( feature = "const_default_impls" , issue = "87864" ) ]
1249
- impl < T > const Default for Box < [ T ] > {
1231
+ impl < T > Default for Box < [ T ] > {
1250
1232
fn default ( ) -> Self {
1251
1233
let ptr: Unique < [ T ] > = Unique :: < [ T ; 0 ] > :: dangling ( ) ;
1252
1234
Box ( ptr, Global )
@@ -1256,7 +1238,7 @@ impl<T> const Default for Box<[T]> {
1256
1238
#[ cfg( not( no_global_oom_handling) ) ]
1257
1239
#[ stable( feature = "default_box_extra" , since = "1.17.0" ) ]
1258
1240
#[ rustc_const_unstable( feature = "const_default_impls" , issue = "87864" ) ]
1259
- impl const Default for Box < str > {
1241
+ impl Default for Box < str > {
1260
1242
fn default ( ) -> Self {
1261
1243
// SAFETY: This is the same as `Unique::cast<U>` but with an unsized `U = str`.
1262
1244
let ptr: Unique < str > = unsafe {
@@ -1452,8 +1434,7 @@ impl<T> From<T> for Box<T> {
1452
1434
}
1453
1435
1454
1436
#[ 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 > >
1457
1438
where
1458
1439
A : ' static ,
1459
1440
{
@@ -1841,8 +1822,7 @@ impl<T: ?Sized, A: Allocator> fmt::Pointer for Box<T, A> {
1841
1822
}
1842
1823
1843
1824
#[ 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 > {
1846
1826
type Target = T ;
1847
1827
1848
1828
fn deref ( & self ) -> & T {
@@ -1851,8 +1831,7 @@ impl<T: ?Sized, A: Allocator> const Deref for Box<T, A> {
1851
1831
}
1852
1832
1853
1833
#[ 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 > {
1856
1835
fn deref_mut ( & mut self ) -> & mut T {
1857
1836
& mut * * self
1858
1837
}
@@ -2031,8 +2010,7 @@ impl<T: ?Sized, A: Allocator> AsMut<T> for Box<T, A> {
2031
2010
* could have a method to project a Pin<T> from it.
2032
2011
*/
2033
2012
#[ 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 { }
2036
2014
2037
2015
#[ unstable( feature = "generator_trait" , issue = "43122" ) ]
2038
2016
impl < G : ?Sized + Generator < R > + Unpin , R , A : Allocator > Generator < R > for Box < G , A >
0 commit comments