@@ -717,57 +717,57 @@ impl<'a, 'b> ReplaceBodyWithLoop<'a, 'b> {
717717 }
718718
719719 fn should_ignore_fn ( ret_ty : & ast:: FnRetTy ) -> bool {
720- if let ast:: FnRetTy :: Ty ( ref ty) = ret_ty {
721- fn involves_impl_trait ( ty : & ast:: Ty ) -> bool {
722- match ty. kind {
723- ast:: TyKind :: ImplTrait ( ..) => true ,
724- ast:: TyKind :: Slice ( ref subty)
725- | ast:: TyKind :: Array ( ref subty, _)
726- | ast:: TyKind :: Ptr ( ast:: MutTy { ty : ref subty, .. } )
727- | ast:: TyKind :: Rptr ( _, ast:: MutTy { ty : ref subty, .. } )
728- | ast:: TyKind :: Paren ( ref subty) => involves_impl_trait ( subty) ,
729- ast:: TyKind :: Tup ( ref tys) => any_involves_impl_trait ( tys. iter ( ) ) ,
730- ast:: TyKind :: Path ( _, ref path) => {
731- path. segments . iter ( ) . any ( |seg| match seg. args . as_deref ( ) {
732- None => false ,
733- Some ( & ast:: GenericArgs :: AngleBracketed ( ref data) ) => {
734- data. args . iter ( ) . any ( |arg| match arg {
735- ast:: AngleBracketedArg :: Arg ( arg) => match arg {
736- ast:: GenericArg :: Type ( ty) => involves_impl_trait ( ty) ,
737- ast:: GenericArg :: Lifetime ( _)
738- | ast:: GenericArg :: Const ( _) => false ,
739- } ,
740- ast:: AngleBracketedArg :: Constraint ( c) => match c. kind {
741- ast:: AssocConstraintKind :: Bound { .. } => true ,
742- ast:: AssocConstraintKind :: Equality { ref term } => {
743- match term {
744- Term :: Ty ( ty) => involves_impl_trait ( ty) ,
745- // FIXME(...): This should check if the constant
746- // involves a trait impl, but for now ignore.
747- Term :: Const ( _) => false ,
748- }
720+ let ast:: FnRetTy :: Ty ( ref ty) = ret_ty else {
721+ return false ;
722+ } ;
723+ fn involves_impl_trait ( ty : & ast:: Ty ) -> bool {
724+ match ty. kind {
725+ ast:: TyKind :: ImplTrait ( ..) => true ,
726+ ast:: TyKind :: Slice ( ref subty)
727+ | ast:: TyKind :: Array ( ref subty, _)
728+ | ast:: TyKind :: Ptr ( ast:: MutTy { ty : ref subty, .. } )
729+ | ast:: TyKind :: Rptr ( _, ast:: MutTy { ty : ref subty, .. } )
730+ | ast:: TyKind :: Paren ( ref subty) => involves_impl_trait ( subty) ,
731+ ast:: TyKind :: Tup ( ref tys) => any_involves_impl_trait ( tys. iter ( ) ) ,
732+ ast:: TyKind :: Path ( _, ref path) => {
733+ path. segments . iter ( ) . any ( |seg| match seg. args . as_deref ( ) {
734+ None => false ,
735+ Some ( & ast:: GenericArgs :: AngleBracketed ( ref data) ) => {
736+ data. args . iter ( ) . any ( |arg| match arg {
737+ ast:: AngleBracketedArg :: Arg ( arg) => match arg {
738+ ast:: GenericArg :: Type ( ty) => involves_impl_trait ( ty) ,
739+ ast:: GenericArg :: Lifetime ( _) | ast:: GenericArg :: Const ( _) => {
740+ false
741+ }
742+ } ,
743+ ast:: AngleBracketedArg :: Constraint ( c) => match c. kind {
744+ ast:: AssocConstraintKind :: Bound { .. } => true ,
745+ ast:: AssocConstraintKind :: Equality { ref term } => {
746+ match term {
747+ Term :: Ty ( ty) => involves_impl_trait ( ty) ,
748+ // FIXME(...): This should check if the constant
749+ // involves a trait impl, but for now ignore.
750+ Term :: Const ( _) => false ,
749751 }
750- } ,
751- } )
752- }
753- Some ( & ast:: GenericArgs :: Parenthesized ( ref data) ) => {
754- any_involves_impl_trait ( data. inputs . iter ( ) )
755- || ReplaceBodyWithLoop :: should_ignore_fn ( & data. output )
756- }
757- } )
758- }
759- _ => false ,
752+ }
753+ } ,
754+ } )
755+ }
756+ Some ( & ast:: GenericArgs :: Parenthesized ( ref data) ) => {
757+ any_involves_impl_trait ( data. inputs . iter ( ) )
758+ || ReplaceBodyWithLoop :: should_ignore_fn ( & data. output )
759+ }
760+ } )
760761 }
762+ _ => false ,
761763 }
764+ }
762765
763- fn any_involves_impl_trait < ' a , I : Iterator < Item = & ' a P < ast:: Ty > > > ( mut it : I ) -> bool {
764- it. any ( |subty| involves_impl_trait ( subty) )
765- }
766-
767- involves_impl_trait ( ty)
768- } else {
769- false
766+ fn any_involves_impl_trait < ' a , I : Iterator < Item = & ' a P < ast:: Ty > > > ( mut it : I ) -> bool {
767+ it. any ( |subty| involves_impl_trait ( subty) )
770768 }
769+
770+ involves_impl_trait ( ty)
771771 }
772772
773773 fn is_sig_const ( sig : & ast:: FnSig ) -> bool {
0 commit comments