@@ -61,26 +61,39 @@ pub(super) fn check(cx: &LateContext<'_>, e: &hir::Expr<'_>, recv: &hir::Expr<'_
61
61
}
62
62
}
63
63
} ,
64
+ hir:: ExprKind :: Call ( call, [ _] ) => {
65
+ if let hir:: ExprKind :: Path ( qpath) = call. kind {
66
+ handle_path ( cx, call, & qpath, e, recv) ;
67
+ }
68
+ } ,
64
69
_ => { } ,
65
70
}
66
71
} ,
67
72
_ => { } ,
68
73
}
69
74
} ,
70
- hir:: ExprKind :: Path ( qpath) => {
71
- if let Some ( path_def_id) = cx. qpath_res ( & qpath, arg. hir_id ) . opt_def_id ( )
72
- && match_def_path ( cx, path_def_id, & paths:: CLONE_TRAIT_METHOD )
73
- {
74
- // FIXME: It would be better to infer the type to check if it's copyable or not
75
- // to suggest to use `.copied()` instead of `.cloned()` where applicable.
76
- lint_path ( cx, e. span , recv. span ) ;
77
- }
78
- } ,
75
+ hir:: ExprKind :: Path ( qpath) => handle_path ( cx, arg, & qpath, e, recv) ,
79
76
_ => { } ,
80
77
}
81
78
}
82
79
}
83
80
81
+ fn handle_path (
82
+ cx : & LateContext < ' _ > ,
83
+ arg : & hir:: Expr < ' _ > ,
84
+ qpath : & hir:: QPath < ' _ > ,
85
+ e : & hir:: Expr < ' _ > ,
86
+ recv : & hir:: Expr < ' _ > ,
87
+ ) {
88
+ if let Some ( path_def_id) = cx. qpath_res ( qpath, arg. hir_id ) . opt_def_id ( )
89
+ && match_def_path ( cx, path_def_id, & paths:: CLONE_TRAIT_METHOD )
90
+ {
91
+ // FIXME: It would be better to infer the type to check if it's copyable or not
92
+ // to suggest to use `.copied()` instead of `.cloned()` where applicable.
93
+ lint_path ( cx, e. span , recv. span ) ;
94
+ }
95
+ }
96
+
84
97
fn ident_eq ( name : Ident , path : & hir:: Expr < ' _ > ) -> bool {
85
98
if let hir:: ExprKind :: Path ( hir:: QPath :: Resolved ( None , path) ) = path. kind {
86
99
path. segments . len ( ) == 1 && path. segments [ 0 ] . ident == name
0 commit comments