@@ -546,7 +546,7 @@ pub macro declare_arena([$($a:tt $name:ident: $ty:ty,)*]) {
546
546
$( $name: $crate:: TypedArena <$ty>, ) *
547
547
}
548
548
549
- pub trait ArenaAllocatable < ' tcx , T = Self > : Sized {
549
+ pub trait ArenaAllocatable < ' tcx , C = rustc_arena :: IsNotCopy > : Sized {
550
550
fn allocate_on < ' a > ( self , arena : & ' a Arena < ' tcx > ) -> & ' a mut Self ;
551
551
fn allocate_from_iter < ' a > (
552
552
arena : & ' a Arena < ' tcx > ,
@@ -555,7 +555,7 @@ pub macro declare_arena([$($a:tt $name:ident: $ty:ty,)*]) {
555
555
}
556
556
557
557
// Any type that impls `Copy` can be arena-allocated in the `DroplessArena`.
558
- impl < ' tcx , T : Copy > ArenaAllocatable < ' tcx , ( ) > for T {
558
+ impl < ' tcx , T : Copy > ArenaAllocatable < ' tcx , rustc_arena :: IsCopy > for T {
559
559
#[ inline]
560
560
fn allocate_on < ' a > ( self , arena : & ' a Arena < ' tcx > ) -> & ' a mut Self {
561
561
arena. dropless . alloc ( self )
@@ -569,7 +569,7 @@ pub macro declare_arena([$($a:tt $name:ident: $ty:ty,)*]) {
569
569
}
570
570
}
571
571
$(
572
- impl<' tcx> ArenaAllocatable <' tcx, $ty > for $ty {
572
+ impl<' tcx> ArenaAllocatable <' tcx, rustc_arena :: IsNotCopy > for $ty {
573
573
#[ inline]
574
574
fn allocate_on < ' a > ( self , arena : & ' a Arena < ' tcx > ) -> & ' a mut Self {
575
575
if !:: std:: mem:: needs_drop :: < Self > ( ) {
@@ -595,7 +595,7 @@ pub macro declare_arena([$($a:tt $name:ident: $ty:ty,)*]) {
595
595
596
596
impl<' tcx> Arena <' tcx> {
597
597
#[ inline]
598
- pub fn alloc < T : ArenaAllocatable < ' tcx , U > , U > ( & self , value : T ) -> & mut T {
598
+ pub fn alloc < T : ArenaAllocatable < ' tcx , C > , C > ( & self , value : T ) -> & mut T {
599
599
value. allocate_on ( self )
600
600
}
601
601
@@ -608,7 +608,7 @@ pub macro declare_arena([$($a:tt $name:ident: $ty:ty,)*]) {
608
608
self . dropless . alloc_slice ( value)
609
609
}
610
610
611
- pub fn alloc_from_iter < ' a , T : ArenaAllocatable < ' tcx , U > , U > (
611
+ pub fn alloc_from_iter < ' a , T : ArenaAllocatable < ' tcx , C > , C > (
612
612
& ' a self ,
613
613
iter : impl :: std:: iter:: IntoIterator < Item = T > ,
614
614
) -> & ' a mut [ T ] {
@@ -617,5 +617,10 @@ pub macro declare_arena([$($a:tt $name:ident: $ty:ty,)*]) {
617
617
}
618
618
}
619
619
620
+ // Marker types that let us give different behaviour for arenas allocating
621
+ // `Copy` types vs `!Copy` types.
622
+ pub struct IsCopy ;
623
+ pub struct IsNotCopy ;
624
+
620
625
#[ cfg( test) ]
621
626
mod tests;
0 commit comments