2222#![ feature( strict_provenance) ]
2323#![ deny( rustc:: untranslatable_diagnostic) ]
2424#![ deny( rustc:: diagnostic_outside_of_impl) ]
25+ #![ allow( clippy:: mut_from_ref) ] // Arena allocators are one of the places where this pattern is fine.
2526
2627use smallvec:: SmallVec ;
2728
@@ -568,7 +569,9 @@ pub macro declare_arena([$($a:tt $name:ident: $ty:ty,)*]) {
568569 }
569570
570571 pub trait ArenaAllocatable < ' tcx , C = rustc_arena:: IsNotCopy > : Sized {
572+ #[ allow( clippy:: mut_from_ref) ]
571573 fn allocate_on < ' a > ( self , arena : & ' a Arena < ' tcx > ) -> & ' a mut Self ;
574+ #[ allow( clippy:: mut_from_ref) ]
572575 fn allocate_from_iter < ' a > (
573576 arena : & ' a Arena < ' tcx > ,
574577 iter : impl :: std:: iter:: IntoIterator < Item = Self > ,
@@ -578,10 +581,12 @@ pub macro declare_arena([$($a:tt $name:ident: $ty:ty,)*]) {
578581 // Any type that impls `Copy` can be arena-allocated in the `DroplessArena`.
579582 impl < ' tcx , T : Copy > ArenaAllocatable < ' tcx , rustc_arena:: IsCopy > for T {
580583 #[ inline]
584+ #[ allow( clippy:: mut_from_ref) ]
581585 fn allocate_on < ' a > ( self , arena : & ' a Arena < ' tcx > ) -> & ' a mut Self {
582586 arena. dropless . alloc ( self )
583587 }
584588 #[ inline]
589+ #[ allow( clippy:: mut_from_ref) ]
585590 fn allocate_from_iter < ' a > (
586591 arena : & ' a Arena < ' tcx > ,
587592 iter : impl :: std:: iter:: IntoIterator < Item = Self > ,
@@ -601,6 +606,7 @@ pub macro declare_arena([$($a:tt $name:ident: $ty:ty,)*]) {
601606 }
602607
603608 #[ inline]
609+ #[ allow( clippy:: mut_from_ref) ]
604610 fn allocate_from_iter < ' a > (
605611 arena : & ' a Arena < ' tcx > ,
606612 iter : impl :: std:: iter:: IntoIterator < Item = Self > ,
@@ -616,19 +622,22 @@ pub macro declare_arena([$($a:tt $name:ident: $ty:ty,)*]) {
616622
617623 impl<' tcx> Arena <' tcx> {
618624 #[ inline]
625+ #[ allow( clippy:: mut_from_ref) ]
619626 pub fn alloc < T : ArenaAllocatable < ' tcx , C > , C > ( & self , value : T ) -> & mut T {
620627 value. allocate_on ( self )
621628 }
622629
623630 // Any type that impls `Copy` can have slices be arena-allocated in the `DroplessArena`.
624631 #[ inline]
632+ #[ allow( clippy:: mut_from_ref) ]
625633 pub fn alloc_slice < T : :: std:: marker:: Copy > ( & self , value : & [ T ] ) -> & mut [ T ] {
626634 if value. is_empty ( ) {
627635 return & mut [ ] ;
628636 }
629637 self . dropless . alloc_slice ( value)
630638 }
631639
640+ #[ allow( clippy:: mut_from_ref) ]
632641 pub fn alloc_from_iter < ' a , T : ArenaAllocatable < ' tcx , C > , C > (
633642 & ' a self ,
634643 iter : impl :: std:: iter:: IntoIterator < Item = T > ,
0 commit comments