@@ -2777,8 +2777,7 @@ impl<'a: 'ast, 'ast, 'tcx> LateResolutionVisitor<'a, '_, 'ast, 'tcx> {
27772777 || lt. kind == MissingLifetimeKind :: Underscore )
27782778 {
27792779 let pre = if lt. kind == MissingLifetimeKind :: Ampersand
2780- && let Some ( ( kind, _span) ) =
2781- self . diagnostic_metadata . current_function
2780+ && let Some ( ( kind, _span) ) = self . diagnostic_metadata . current_function
27822781 && let FnKind :: Fn ( _, _, sig, _, _, _) = kind
27832782 && !sig. decl . inputs . is_empty ( )
27842783 && let sugg = sig
@@ -2803,7 +2802,6 @@ impl<'a: 'ast, 'ast, 'tcx> LateResolutionVisitor<'a, '_, 'ast, 'tcx> {
28032802 . collect :: < Vec < _ > > ( )
28042803 && !sugg. is_empty ( )
28052804 {
2806-
28072805 let ( the, s) = if sig. decl . inputs . len ( ) == 1 {
28082806 ( "the" , "" )
28092807 } else {
@@ -2819,9 +2817,8 @@ impl<'a: 'ast, 'ast, 'tcx> LateResolutionVisitor<'a, '_, 'ast, 'tcx> {
28192817 ) ;
28202818 "...or alternatively, you might want"
28212819 } else if ( lt. kind == MissingLifetimeKind :: Ampersand
2822- || lt. kind == MissingLifetimeKind :: Underscore )
2823- && let Some ( ( kind, _span) ) =
2824- self . diagnostic_metadata . current_function
2820+ || lt. kind == MissingLifetimeKind :: Underscore )
2821+ && let Some ( ( kind, _span) ) = self . diagnostic_metadata . current_function
28252822 && let FnKind :: Fn ( _, _, sig, _, _, _) = kind
28262823 && let ast:: FnRetTy :: Ty ( ret_ty) = & sig. decl . output
28272824 && !sig. decl . inputs . is_empty ( )
@@ -2842,26 +2839,25 @@ impl<'a: 'ast, 'ast, 'tcx> LateResolutionVisitor<'a, '_, 'ast, 'tcx> {
28422839 // So we look at every ref in the trait bound. If there's any, we
28432840 // suggest
28442841 // fn g<'a>(mut x: impl Iterator<Item = &'a ()>) -> Option<&'a ()>
2845- let mut lt_finder = LifetimeFinder {
2846- lifetime : lt. span ,
2847- found : None ,
2848- seen : vec ! [ ] ,
2849- } ;
2842+ let mut lt_finder =
2843+ LifetimeFinder { lifetime : lt. span , found : None , seen : vec ! [ ] } ;
28502844 for bound in arg_refs {
28512845 if let ast:: GenericBound :: Trait ( trait_ref, _) = bound {
28522846 lt_finder. visit_trait_ref ( & trait_ref. trait_ref ) ;
28532847 }
28542848 }
28552849 lt_finder. visit_ty ( ret_ty) ;
2856- let spans_suggs: Vec < _ > = lt_finder. seen . iter ( ) . filter_map ( |ty| {
2857- match & ty. kind {
2850+ let spans_suggs: Vec < _ > = lt_finder
2851+ . seen
2852+ . iter ( )
2853+ . filter_map ( |ty| match & ty. kind {
28582854 TyKind :: Ref ( _, mut_ty) => {
28592855 let span = ty. span . with_hi ( mut_ty. ty . span . lo ( ) ) ;
28602856 Some ( ( span, "&'a " . to_string ( ) ) )
28612857 }
2862- _ => None
2863- }
2864- } ) . collect ( ) ;
2858+ _ => None ,
2859+ } )
2860+ . collect ( ) ;
28652861 self . suggest_introducing_lifetime (
28662862 err,
28672863 None ,
@@ -2882,20 +2878,16 @@ impl<'a: 'ast, 'ast, 'tcx> LateResolutionVisitor<'a, '_, 'ast, 'tcx> {
28822878 } ;
28832879 let mut owned_sugg = lt. kind == MissingLifetimeKind :: Ampersand ;
28842880 let mut sugg = vec ! [ ( lt. span, String :: new( ) ) ] ;
2885- if let Some ( ( kind, _span) ) =
2886- self . diagnostic_metadata . current_function
2881+ if let Some ( ( kind, _span) ) = self . diagnostic_metadata . current_function
28872882 && let FnKind :: Fn ( _, _, sig, _, _, _) = kind
28882883 && let ast:: FnRetTy :: Ty ( ty) = & sig. decl . output
28892884 {
2890- let mut lt_finder = LifetimeFinder {
2891- lifetime : lt. span ,
2892- found : None ,
2893- seen : vec ! [ ] ,
2894- } ;
2885+ let mut lt_finder =
2886+ LifetimeFinder { lifetime : lt. span , found : None , seen : vec ! [ ] } ;
28952887 lt_finder. visit_ty ( & ty) ;
28962888
2897- if let [ Ty { span, kind : TyKind :: Ref ( _, mut_ty) , ..} ]
2898- = & lt_finder. seen [ ..]
2889+ if let [ Ty { span, kind : TyKind :: Ref ( _, mut_ty) , .. } ] =
2890+ & lt_finder. seen [ ..]
28992891 {
29002892 // We might have a situation like
29012893 // fn g(mut x: impl Iterator<Item = &'_ ()>) -> Option<&'_ ()>
@@ -2910,9 +2902,7 @@ impl<'a: 'ast, 'ast, 'tcx> LateResolutionVisitor<'a, '_, 'ast, 'tcx> {
29102902 // Check if the path being borrowed is likely to be owned.
29112903 let path: Vec < _ > = Segment :: from_path ( path) ;
29122904 match self . resolve_path ( & path, Some ( TypeNS ) , None ) {
2913- PathResult :: Module (
2914- ModuleOrUniformRoot :: Module ( module) ,
2915- ) => {
2905+ PathResult :: Module ( ModuleOrUniformRoot :: Module ( module) ) => {
29162906 match module. res ( ) {
29172907 Some ( Res :: PrimTy ( PrimTy :: Str ) ) => {
29182908 // Don't suggest `-> str`, suggest `-> String`.
@@ -2932,7 +2922,8 @@ impl<'a: 'ast, 'ast, 'tcx> LateResolutionVisitor<'a, '_, 'ast, 'tcx> {
29322922 | DefKind :: TyParam ,
29332923 _,
29342924 ) ) => { }
2935- _ => { // Do not suggest in all other cases.
2925+ _ => {
2926+ // Do not suggest in all other cases.
29362927 owned_sugg = false ;
29372928 }
29382929 }
@@ -2957,12 +2948,14 @@ impl<'a: 'ast, 'ast, 'tcx> LateResolutionVisitor<'a, '_, 'ast, 'tcx> {
29572948 | DefKind :: TyParam ,
29582949 _,
29592950 ) => { }
2960- _ => { // Do not suggest in all other cases.
2951+ _ => {
2952+ // Do not suggest in all other cases.
29612953 owned_sugg = false ;
29622954 }
29632955 }
29642956 }
2965- _ => { // Do not suggest in all other cases.
2957+ _ => {
2958+ // Do not suggest in all other cases.
29662959 owned_sugg = false ;
29672960 }
29682961 }
0 commit comments