@@ -2906,60 +2906,65 @@ impl<'a: 'ast, 'ast, 'tcx> LateResolutionVisitor<'a, '_, 'ast, 'tcx> {
2906
2906
owned_sugg = true ;
2907
2907
}
2908
2908
if let Some ( ty) = lt_finder. found {
2909
- if let TyKind :: Path ( None , path @ Path { segments, .. } ) = & ty. kind
2910
- && segments. len ( ) == 1
2911
- {
2912
- if segments[ 0 ] . ident . name == sym:: str {
2913
- // Don't suggest `-> str`, suggest `-> String`.
2914
- sugg = vec ! [
2915
- ( lt. span. with_hi( ty. span. hi( ) ) , "String" . to_string( ) ) ,
2916
- ] ;
2917
- } else {
2918
- // Check if the path being borrowed is likely to be owned.
2919
- let path: Vec < _ > = Segment :: from_path ( path) ;
2920
- match self . resolve_path ( & path, Some ( TypeNS ) , None ) {
2921
- PathResult :: Module (
2922
- ModuleOrUniformRoot :: Module ( module) ,
2923
- ) => {
2924
- match module. res ( ) {
2925
- Some ( Res :: PrimTy ( ..) ) => { }
2926
- Some ( Res :: Def (
2927
- DefKind :: Struct
2928
- | DefKind :: Union
2929
- | DefKind :: Enum
2930
- | DefKind :: ForeignTy
2931
- | DefKind :: AssocTy
2932
- | DefKind :: OpaqueTy
2933
- | DefKind :: TyParam ,
2934
- _,
2935
- ) ) => { }
2936
- _ => { // Do not suggest in all other cases.
2937
- owned_sugg = false ;
2938
- }
2909
+ if let TyKind :: Path ( None , path) = & ty. kind {
2910
+ // Check if the path being borrowed is likely to be owned.
2911
+ let path: Vec < _ > = Segment :: from_path ( path) ;
2912
+ match self . resolve_path ( & path, Some ( TypeNS ) , None ) {
2913
+ PathResult :: Module (
2914
+ ModuleOrUniformRoot :: Module ( module) ,
2915
+ ) => {
2916
+ match module. res ( ) {
2917
+ Some ( Res :: PrimTy ( PrimTy :: Str ) ) => {
2918
+ // Don't suggest `-> str`, suggest `-> String`.
2919
+ sugg = vec ! [ (
2920
+ lt. span. with_hi( ty. span. hi( ) ) ,
2921
+ "String" . to_string( ) ,
2922
+ ) ] ;
2939
2923
}
2940
- }
2941
- PathResult :: NonModule ( res) => {
2942
- match res. base_res ( ) {
2943
- Res :: PrimTy ( ..) => { }
2944
- Res :: Def (
2945
- DefKind :: Struct
2946
- | DefKind :: Union
2947
- | DefKind :: Enum
2948
- | DefKind :: ForeignTy
2949
- | DefKind :: AssocTy
2950
- | DefKind :: OpaqueTy
2951
- | DefKind :: TyParam ,
2952
- _,
2953
- ) => { }
2954
- _ => { // Do not suggest in all other cases.
2955
- owned_sugg = false ;
2956
- }
2924
+ Some ( Res :: PrimTy ( ..) ) => { }
2925
+ Some ( Res :: Def (
2926
+ DefKind :: Struct
2927
+ | DefKind :: Union
2928
+ | DefKind :: Enum
2929
+ | DefKind :: ForeignTy
2930
+ | DefKind :: AssocTy
2931
+ | DefKind :: OpaqueTy
2932
+ | DefKind :: TyParam ,
2933
+ _,
2934
+ ) ) => { }
2935
+ _ => { // Do not suggest in all other cases.
2936
+ owned_sugg = false ;
2957
2937
}
2958
2938
}
2959
- _ => { // Do not suggest in all other cases.
2960
- owned_sugg = false ;
2939
+ }
2940
+ PathResult :: NonModule ( res) => {
2941
+ match res. base_res ( ) {
2942
+ Res :: PrimTy ( PrimTy :: Str ) => {
2943
+ // Don't suggest `-> str`, suggest `-> String`.
2944
+ sugg = vec ! [ (
2945
+ lt. span. with_hi( ty. span. hi( ) ) ,
2946
+ "String" . to_string( ) ,
2947
+ ) ] ;
2948
+ }
2949
+ Res :: PrimTy ( ..) => { }
2950
+ Res :: Def (
2951
+ DefKind :: Struct
2952
+ | DefKind :: Union
2953
+ | DefKind :: Enum
2954
+ | DefKind :: ForeignTy
2955
+ | DefKind :: AssocTy
2956
+ | DefKind :: OpaqueTy
2957
+ | DefKind :: TyParam ,
2958
+ _,
2959
+ ) => { }
2960
+ _ => { // Do not suggest in all other cases.
2961
+ owned_sugg = false ;
2962
+ }
2961
2963
}
2962
2964
}
2965
+ _ => { // Do not suggest in all other cases.
2966
+ owned_sugg = false ;
2967
+ }
2963
2968
}
2964
2969
}
2965
2970
if let TyKind :: Slice ( inner_ty) = & ty. kind {
0 commit comments