22
22
#![ feature( strict_provenance) ]
23
23
#![ deny( rustc:: untranslatable_diagnostic) ]
24
24
#![ deny( rustc:: diagnostic_outside_of_impl) ]
25
+ #![ allow( clippy:: mut_from_ref) ] // Arena allocators are one of the places where this pattern is fine.
25
26
26
27
use smallvec:: SmallVec ;
27
28
@@ -568,7 +569,9 @@ pub macro declare_arena([$($a:tt $name:ident: $ty:ty,)*]) {
568
569
}
569
570
570
571
pub trait ArenaAllocatable < ' tcx , C = rustc_arena:: IsNotCopy > : Sized {
572
+ #[ allow( clippy:: mut_from_ref) ]
571
573
fn allocate_on < ' a > ( self , arena : & ' a Arena < ' tcx > ) -> & ' a mut Self ;
574
+ #[ allow( clippy:: mut_from_ref) ]
572
575
fn allocate_from_iter < ' a > (
573
576
arena : & ' a Arena < ' tcx > ,
574
577
iter : impl :: std:: iter:: IntoIterator < Item = Self > ,
@@ -578,10 +581,12 @@ pub macro declare_arena([$($a:tt $name:ident: $ty:ty,)*]) {
578
581
// Any type that impls `Copy` can be arena-allocated in the `DroplessArena`.
579
582
impl < ' tcx , T : Copy > ArenaAllocatable < ' tcx , rustc_arena:: IsCopy > for T {
580
583
#[ inline]
584
+ #[ allow( clippy:: mut_from_ref) ]
581
585
fn allocate_on < ' a > ( self , arena : & ' a Arena < ' tcx > ) -> & ' a mut Self {
582
586
arena. dropless . alloc ( self )
583
587
}
584
588
#[ inline]
589
+ #[ allow( clippy:: mut_from_ref) ]
585
590
fn allocate_from_iter < ' a > (
586
591
arena : & ' a Arena < ' tcx > ,
587
592
iter : impl :: std:: iter:: IntoIterator < Item = Self > ,
@@ -601,6 +606,7 @@ pub macro declare_arena([$($a:tt $name:ident: $ty:ty,)*]) {
601
606
}
602
607
603
608
#[ inline]
609
+ #[ allow( clippy:: mut_from_ref) ]
604
610
fn allocate_from_iter < ' a > (
605
611
arena : & ' a Arena < ' tcx > ,
606
612
iter : impl :: std:: iter:: IntoIterator < Item = Self > ,
@@ -616,19 +622,22 @@ pub macro declare_arena([$($a:tt $name:ident: $ty:ty,)*]) {
616
622
617
623
impl<' tcx> Arena <' tcx> {
618
624
#[ inline]
625
+ #[ allow( clippy:: mut_from_ref) ]
619
626
pub fn alloc < T : ArenaAllocatable < ' tcx , C > , C > ( & self , value : T ) -> & mut T {
620
627
value. allocate_on ( self )
621
628
}
622
629
623
630
// Any type that impls `Copy` can have slices be arena-allocated in the `DroplessArena`.
624
631
#[ inline]
632
+ #[ allow( clippy:: mut_from_ref) ]
625
633
pub fn alloc_slice < T : :: std:: marker:: Copy > ( & self , value : & [ T ] ) -> & mut [ T ] {
626
634
if value. is_empty ( ) {
627
635
return & mut [ ] ;
628
636
}
629
637
self . dropless . alloc_slice ( value)
630
638
}
631
639
640
+ #[ allow( clippy:: mut_from_ref) ]
632
641
pub fn alloc_from_iter < ' a , T : ArenaAllocatable < ' tcx , C > , C > (
633
642
& ' a self ,
634
643
iter : impl :: std:: iter:: IntoIterator < Item = T > ,
0 commit comments