33
33
//! }
34
34
//!
35
35
//! let list: List<i32> = List::Cons(1, Box::new(List::Cons(2, Box::new(List::Nil))));
36
- //! println!("{:?}", list );
36
+ //! println!("{list :?}");
37
37
//! ```
38
38
//!
39
39
//! This will print `Cons(1, Cons(2, Nil))`.
@@ -145,7 +145,7 @@ use core::hash::{Hash, Hasher};
145
145
#[ cfg( not( no_global_oom_handling) ) ]
146
146
use core:: iter:: FromIterator ;
147
147
use core:: iter:: { FusedIterator , Iterator } ;
148
- use core:: marker:: { Unpin , Unsize } ;
148
+ use core:: marker:: { Destruct , Unpin , Unsize } ;
149
149
use core:: mem;
150
150
use core:: ops:: {
151
151
CoerceUnsized , Deref , DerefMut , DispatchFromDyn , Generator , GeneratorState , Receiver ,
@@ -351,9 +351,10 @@ impl<T, A: Allocator> Box<T, A> {
351
351
#[ rustc_const_unstable( feature = "const_box" , issue = "92521" ) ]
352
352
#[ must_use]
353
353
#[ inline]
354
+ #[ cfg_attr( not( bootstrap) , allow( drop_bounds) ) ] // FIXME remove `~const Drop` and this attr when bumping
354
355
pub const fn new_in ( x : T , alloc : A ) -> Self
355
356
where
356
- A : ~const Allocator + ~const Drop ,
357
+ A : ~const Allocator + ~const Drop + ~ const Destruct ,
357
358
{
358
359
let mut boxed = Self :: new_uninit_in ( alloc) ;
359
360
unsafe {
@@ -380,10 +381,11 @@ impl<T, A: Allocator> Box<T, A> {
380
381
#[ unstable( feature = "allocator_api" , issue = "32838" ) ]
381
382
#[ rustc_const_unstable( feature = "const_box" , issue = "92521" ) ]
382
383
#[ inline]
384
+ #[ cfg_attr( not( bootstrap) , allow( drop_bounds) ) ] // FIXME remove `~const Drop` and this attr when bumping
383
385
pub const fn try_new_in ( x : T , alloc : A ) -> Result < Self , AllocError >
384
386
where
385
- T : ~const Drop ,
386
- A : ~const Allocator + ~const Drop ,
387
+ T : ~const Drop + ~ const Destruct ,
388
+ A : ~const Allocator + ~const Drop + ~ const Destruct ,
387
389
{
388
390
let mut boxed = Self :: try_new_uninit_in ( alloc) ?;
389
391
unsafe {
@@ -417,9 +419,10 @@ impl<T, A: Allocator> Box<T, A> {
417
419
#[ cfg( not( no_global_oom_handling) ) ]
418
420
#[ must_use]
419
421
// #[unstable(feature = "new_uninit", issue = "63291")]
422
+ #[ cfg_attr( not( bootstrap) , allow( drop_bounds) ) ] // FIXME remove `~const Drop` and this attr when bumping
420
423
pub const fn new_uninit_in ( alloc : A ) -> Box < mem:: MaybeUninit < T > , A >
421
424
where
422
- A : ~const Allocator + ~const Drop ,
425
+ A : ~const Allocator + ~const Drop + ~ const Destruct ,
423
426
{
424
427
let layout = Layout :: new :: < mem:: MaybeUninit < T > > ( ) ;
425
428
// NOTE: Prefer match over unwrap_or_else since closure sometimes not inlineable.
@@ -455,9 +458,10 @@ impl<T, A: Allocator> Box<T, A> {
455
458
#[ unstable( feature = "allocator_api" , issue = "32838" ) ]
456
459
// #[unstable(feature = "new_uninit", issue = "63291")]
457
460
#[ rustc_const_unstable( feature = "const_box" , issue = "92521" ) ]
461
+ #[ cfg_attr( not( bootstrap) , allow( drop_bounds) ) ] // FIXME remove `~const Drop` and this attr when bumping
458
462
pub const fn try_new_uninit_in ( alloc : A ) -> Result < Box < mem:: MaybeUninit < T > , A > , AllocError >
459
463
where
460
- A : ~const Allocator + ~const Drop ,
464
+ A : ~const Allocator + ~const Drop + ~ const Destruct ,
461
465
{
462
466
let layout = Layout :: new :: < mem:: MaybeUninit < T > > ( ) ;
463
467
let ptr = alloc. allocate ( layout) ?. cast ( ) ;
@@ -489,9 +493,10 @@ impl<T, A: Allocator> Box<T, A> {
489
493
#[ cfg( not( no_global_oom_handling) ) ]
490
494
// #[unstable(feature = "new_uninit", issue = "63291")]
491
495
#[ must_use]
496
+ #[ cfg_attr( not( bootstrap) , allow( drop_bounds) ) ] // FIXME remove `~const Drop` and this attr when bumping
492
497
pub const fn new_zeroed_in ( alloc : A ) -> Box < mem:: MaybeUninit < T > , A >
493
498
where
494
- A : ~const Allocator + ~const Drop ,
499
+ A : ~const Allocator + ~const Drop + ~ const Destruct ,
495
500
{
496
501
let layout = Layout :: new :: < mem:: MaybeUninit < T > > ( ) ;
497
502
// NOTE: Prefer match over unwrap_or_else since closure sometimes not inlineable.
@@ -527,9 +532,10 @@ impl<T, A: Allocator> Box<T, A> {
527
532
#[ unstable( feature = "allocator_api" , issue = "32838" ) ]
528
533
// #[unstable(feature = "new_uninit", issue = "63291")]
529
534
#[ rustc_const_unstable( feature = "const_box" , issue = "92521" ) ]
535
+ #[ cfg_attr( not( bootstrap) , allow( drop_bounds) ) ] // FIXME remove `~const Drop` and this attr when bumping
530
536
pub const fn try_new_zeroed_in ( alloc : A ) -> Result < Box < mem:: MaybeUninit < T > , A > , AllocError >
531
537
where
532
- A : ~const Allocator + ~const Drop ,
538
+ A : ~const Allocator + ~const Drop + ~ const Destruct ,
533
539
{
534
540
let layout = Layout :: new :: < mem:: MaybeUninit < T > > ( ) ;
535
541
let ptr = alloc. allocate_zeroed ( layout) ?. cast ( ) ;
@@ -543,9 +549,10 @@ impl<T, A: Allocator> Box<T, A> {
543
549
#[ rustc_const_unstable( feature = "const_box" , issue = "92521" ) ]
544
550
#[ must_use]
545
551
#[ inline( always) ]
552
+ #[ cfg_attr( not( bootstrap) , allow( drop_bounds) ) ] // FIXME remove `~const Drop` and this attr when bumping
546
553
pub const fn pin_in ( x : T , alloc : A ) -> Pin < Self >
547
554
where
548
- A : ' static + ~const Allocator + ~const Drop ,
555
+ A : ' static + ~const Allocator + ~const Drop + ~ const Destruct ,
549
556
{
550
557
Self :: into_pin ( Self :: new_in ( x, alloc) )
551
558
}
@@ -574,9 +581,10 @@ impl<T, A: Allocator> Box<T, A> {
574
581
#[ unstable( feature = "box_into_inner" , issue = "80437" ) ]
575
582
#[ rustc_const_unstable( feature = "const_box" , issue = "92521" ) ]
576
583
#[ inline]
584
+ #[ cfg_attr( not( bootstrap) , allow( drop_bounds) ) ] // FIXME remove `~const Drop` and this attr when bumping
577
585
pub const fn into_inner ( boxed : Self ) -> T
578
586
where
579
- Self : ~const Drop ,
587
+ Self : ~const Drop + ~ const Destruct ,
580
588
{
581
589
* boxed
582
590
}
@@ -1409,7 +1417,7 @@ impl<T: Copy> From<&[T]> for Box<[T]> {
1409
1417
/// let slice: &[u8] = &[104, 101, 108, 108, 111];
1410
1418
/// let boxed_slice: Box<[u8]> = Box::from(slice);
1411
1419
///
1412
- /// println!("{:?}", boxed_slice );
1420
+ /// println!("{boxed_slice :?}");
1413
1421
/// ```
1414
1422
fn from ( slice : & [ T ] ) -> Box < [ T ] > {
1415
1423
let len = slice. len ( ) ;
@@ -1451,7 +1459,7 @@ impl From<&str> for Box<str> {
1451
1459
///
1452
1460
/// ```rust
1453
1461
/// let boxed: Box<str> = Box::from("hello");
1454
- /// println!("{}", boxed );
1462
+ /// println!("{boxed}" );
1455
1463
/// ```
1456
1464
#[ inline]
1457
1465
fn from ( s : & str ) -> Box < str > {
@@ -1476,14 +1484,14 @@ impl From<Cow<'_, str>> for Box<str> {
1476
1484
///
1477
1485
/// let unboxed = Cow::Borrowed("hello");
1478
1486
/// let boxed: Box<str> = Box::from(unboxed);
1479
- /// println!("{}", boxed );
1487
+ /// println!("{boxed}" );
1480
1488
/// ```
1481
1489
///
1482
1490
/// ```rust
1483
1491
/// # use std::borrow::Cow;
1484
1492
/// let unboxed = Cow::Owned("hello".to_string());
1485
1493
/// let boxed: Box<str> = Box::from(unboxed);
1486
- /// println!("{}", boxed );
1494
+ /// println!("{boxed}" );
1487
1495
/// ```
1488
1496
#[ inline]
1489
1497
fn from ( cow : Cow < ' _ , str > ) -> Box < str > {
@@ -1530,7 +1538,7 @@ impl<T, const N: usize> From<[T; N]> for Box<[T]> {
1530
1538
///
1531
1539
/// ```rust
1532
1540
/// let boxed: Box<[u8]> = Box::from([4, 2]);
1533
- /// println!("{:?}", boxed );
1541
+ /// println!("{boxed :?}");
1534
1542
/// ```
1535
1543
fn from ( array : [ T ; N ] ) -> Box < [ T ] > {
1536
1544
box array
0 commit comments