@@ -88,7 +88,7 @@ use core::ptr::{self, NonNull, Unique};
88
88
use core:: task:: { Context , Poll } ;
89
89
90
90
use crate :: alloc:: {
91
- Stage0Alloc as Alloc , Global , Layout , handle_alloc_error, stage0_phantom, stage0_unphantom
91
+ Stage0Alloc as Alloc , AllocHelper , AllocErr , Global , Layout , handle_alloc_error, stage0_phantom, stage0_unphantom
92
92
} ;
93
93
use crate :: vec:: Vec ;
94
94
use crate :: raw_vec:: RawVec ;
@@ -137,7 +137,7 @@ impl<T> Box<T> {
137
137
}
138
138
}
139
139
140
- impl < T , A : Alloc > Box < T , A > {
140
+ impl < T , A : Alloc < Err = AllocErr > > Box < T , A > {
141
141
/// Allocates memory in the given allocator and then places `x` into it.
142
142
///
143
143
/// This doesn't actually allocate if `T` is zero-sized.
@@ -210,7 +210,7 @@ impl<T: ?Sized> Box<T> {
210
210
}
211
211
}
212
212
213
- impl < T : ?Sized , A : Alloc > Box < T , A > {
213
+ impl < T : ?Sized , A > Box < T , A > {
214
214
/// Constructs a box from a raw pointer in the given allocator.
215
215
///
216
216
/// This is similar to the [`Box::from_raw`] function, but assumes
@@ -394,29 +394,29 @@ unsafe impl<#[may_dangle] T: ?Sized, A> Drop for Box<T, A> {
394
394
}
395
395
396
396
#[ stable( feature = "rust1" , since = "1.0.0" ) ]
397
- impl < T : Default , A : Alloc + Default > Default for Box < T , A > {
397
+ impl < T : Default , A : Alloc < Err = AllocErr > + Default > Default for Box < T , A > {
398
398
/// Creates a `Box<T, A>`, with the `Default` value for T.
399
399
fn default ( ) -> Box < T , A > {
400
400
Box :: new_in ( Default :: default ( ) , A :: default ( ) )
401
401
}
402
402
}
403
403
404
404
#[ stable( feature = "rust1" , since = "1.0.0" ) ]
405
- impl < T , A : Alloc + Default > Default for Box < [ T ] , A > {
405
+ impl < T , A : Alloc < Err = AllocErr > + Default > Default for Box < [ T ] , A > {
406
406
fn default ( ) -> Box < [ T ] , A > {
407
407
Box :: < [ T ; 0 ] , A > :: new_in ( [ ] , A :: default ( ) )
408
408
}
409
409
}
410
410
411
411
#[ stable( feature = "default_box_extra" , since = "1.17.0" ) ]
412
- impl < A : Alloc + Default > Default for Box < str , A > {
412
+ impl < A : Alloc < Err = AllocErr > + Default > Default for Box < str , A > {
413
413
fn default ( ) -> Box < str , A > {
414
414
unsafe { from_boxed_utf8_unchecked ( Default :: default ( ) ) }
415
415
}
416
416
}
417
417
418
418
#[ stable( feature = "rust1" , since = "1.0.0" ) ]
419
- impl < T : Clone , A : Alloc + Clone > Clone for Box < T , A > {
419
+ impl < T : Clone , A : Alloc < Err = AllocErr > + Clone > Clone for Box < T , A > {
420
420
/// Returns a new box with a `clone()` of this box's contents.
421
421
///
422
422
/// # Examples
@@ -448,9 +448,8 @@ impl<T: Clone, A: Alloc + Clone> Clone for Box<T, A> {
448
448
}
449
449
}
450
450
451
-
452
451
#[ stable( feature = "box_slice_clone" , since = "1.3.0" ) ]
453
- impl < A : Alloc + Clone > Clone for Box < str , A > {
452
+ impl < A : Alloc < Err = AllocErr > + Clone > Clone for Box < str , A > {
454
453
fn clone ( & self ) -> Self {
455
454
let len = self . len ( ) ;
456
455
let buf = RawVec :: with_capacity_in ( len, stage0_unphantom ( self . 1 . clone ( ) ) ) ;
@@ -559,7 +558,7 @@ impl<T: ?Sized + Hasher, A> Hasher for Box<T, A> {
559
558
}
560
559
561
560
#[ stable( feature = "from_for_ptrs" , since = "1.6.0" ) ]
562
- impl < T , A : Alloc + Default > From < T > for Box < T , A > {
561
+ impl < T , A : Alloc < Err = AllocErr > + Default > From < T > for Box < T , A > {
563
562
/// Converts a generic type `T` into a `Box<T>`
564
563
///
565
564
/// The conversion allocates on the heap and moves `t`
@@ -588,7 +587,7 @@ impl<T: ?Sized, A> From<Box<T, A>> for Pin<Box<T, A>> {
588
587
}
589
588
590
589
#[ stable( feature = "box_from_slice" , since = "1.17.0" ) ]
591
- impl < T : Copy , A : Alloc + Default > From < & [ T ] > for Box < [ T ] , A > {
590
+ impl < T : Copy , A : Alloc < Err = AllocErr > + Default > From < & [ T ] > for Box < [ T ] , A > {
592
591
/// Converts a `&[T]` into a `Box<[T]>`
593
592
///
594
593
/// This conversion allocates on the heap
@@ -611,7 +610,7 @@ impl<T: Copy, A: Alloc + Default> From<&[T]> for Box<[T], A> {
611
610
}
612
611
613
612
#[ stable( feature = "box_from_slice" , since = "1.17.0" ) ]
614
- impl < A : Alloc + Default > From < & str > for Box < str , A > {
613
+ impl < A : Alloc < Err = AllocErr > + Default > From < & str > for Box < str , A > {
615
614
/// Converts a `&str` into a `Box<str>`
616
615
///
617
616
/// This conversion allocates on the heap
@@ -629,7 +628,7 @@ impl<A: Alloc + Default> From<&str> for Box<str, A> {
629
628
}
630
629
631
630
#[ stable( feature = "boxed_str_conv" , since = "1.19.0" ) ]
632
- impl < A : Alloc > From < Box < str , A > > for Box < [ u8 ] , A > {
631
+ impl < A > From < Box < str , A > > for Box < [ u8 ] , A > {
633
632
/// Converts a `Box<str>>` into a `Box<[u8]>`
634
633
///
635
634
/// This conversion does not allocate on the heap and happens in place.
@@ -652,7 +651,7 @@ impl<A: Alloc> From<Box<str, A>> for Box<[u8], A> {
652
651
}
653
652
}
654
653
655
- impl < A : Alloc > Box < dyn Any , A > {
654
+ impl < A > Box < dyn Any , A > {
656
655
#[ inline]
657
656
#[ stable( feature = "rust1" , since = "1.0.0" ) ]
658
657
/// Attempt to downcast the box to a concrete type.
@@ -683,7 +682,7 @@ impl<A: Alloc> Box<dyn Any, A> {
683
682
}
684
683
}
685
684
686
- impl < A : Alloc > Box < dyn Any + Send , A > {
685
+ impl < A : Alloc < Err = AllocErr > > Box < dyn Any + Send , A > {
687
686
#[ inline]
688
687
#[ stable( feature = "rust1" , since = "1.0.0" ) ]
689
688
/// Attempt to downcast the box to a concrete type.
@@ -885,7 +884,7 @@ impl<A> FromIterator<A> for Box<[A]> {
885
884
}
886
885
887
886
#[ stable( feature = "box_slice_clone" , since = "1.3.0" ) ]
888
- impl < T : Clone , A : Alloc + Clone > Clone for Box < [ T ] , A > {
887
+ impl < T : Clone , A : Alloc < Err = AllocErr > + Clone > Clone for Box < [ T ] , A > {
889
888
fn clone ( & self ) -> Self {
890
889
let mut new = BoxBuilder {
891
890
data : RawVec :: with_capacity_in ( self . len ( ) , stage0_unphantom ( self . 1 . clone ( ) ) ) ,
@@ -906,20 +905,20 @@ impl<T: Clone, A: Alloc + Clone> Clone for Box<[T], A> {
906
905
return unsafe { new. into_box ( ) } ;
907
906
908
907
// Helper type for responding to panics correctly.
909
- struct BoxBuilder < T , A : Alloc > {
908
+ struct BoxBuilder < T , A : Alloc < Err = AllocErr > + AllocHelper < Err = AllocErr > > {
910
909
data : RawVec < T , A > ,
911
910
len : usize ,
912
911
}
913
912
914
- impl < T , A : Alloc > BoxBuilder < T , A > {
913
+ impl < T , A : Alloc < Err = AllocErr > > BoxBuilder < T , A > {
915
914
unsafe fn into_box ( self ) -> Box < [ T ] , A > {
916
915
let raw = ptr:: read ( & self . data ) ;
917
916
mem:: forget ( self ) ;
918
917
raw. into_box ( )
919
918
}
920
919
}
921
920
922
- impl < T , A : Alloc > Drop for BoxBuilder < T , A > {
921
+ impl < T , A : Alloc < Err = AllocErr > > Drop for BoxBuilder < T , A > {
923
922
fn drop ( & mut self ) {
924
923
let mut data = self . data . ptr ( ) ;
925
924
let max = unsafe { data. add ( self . len ) } ;
0 commit comments