@@ -4840,8 +4840,6 @@ impl<'tcx> LateLintPass<'tcx> for Methods {
4840
4840
return ;
4841
4841
}
4842
4842
4843
- self . check_methods ( cx, expr) ;
4844
-
4845
4843
match expr. kind {
4846
4844
ExprKind :: Call ( func, args) => {
4847
4845
from_iter_instead_of_collect:: check ( cx, expr, args, func) ;
@@ -4852,24 +4850,8 @@ impl<'tcx> LateLintPass<'tcx> for Methods {
4852
4850
swap_with_temporary:: check ( cx, expr, func, args) ;
4853
4851
ip_constant:: check ( cx, expr, func, args) ;
4854
4852
} ,
4855
- ExprKind :: MethodCall ( method_call, receiver, args, _) => {
4856
- let method_span = method_call. ident . span ;
4857
- or_fun_call:: check ( cx, expr, method_span, method_call. ident . name , receiver, args, self . msrv ) ;
4858
- expect_fun_call:: check (
4859
- cx,
4860
- & self . format_args ,
4861
- expr,
4862
- method_span,
4863
- method_call. ident . name ,
4864
- receiver,
4865
- args,
4866
- ) ;
4867
- clone_on_copy:: check ( cx, expr, method_call. ident . name , receiver, args) ;
4868
- clone_on_ref_ptr:: check ( cx, expr, method_call. ident . name , receiver, args) ;
4869
- inefficient_to_string:: check ( cx, expr, method_call. ident . name , receiver, args) ;
4870
- single_char_add_str:: check ( cx, expr, receiver, args) ;
4871
- into_iter_on_ref:: check ( cx, expr, method_span, method_call. ident . name , receiver) ;
4872
- unnecessary_to_owned:: check ( cx, expr, method_call. ident . name , receiver, args, self . msrv ) ;
4853
+ ExprKind :: MethodCall ( ..) => {
4854
+ self . check_methods ( cx, expr) ;
4873
4855
} ,
4874
4856
ExprKind :: Binary ( op, lhs, rhs) if op. node == hir:: BinOpKind :: Eq || op. node == hir:: BinOpKind :: Ne => {
4875
4857
let mut info = BinaryExprInfo {
@@ -5617,7 +5599,17 @@ impl Methods {
5617
5599
}
5618
5600
// Handle method calls whose receiver and arguments may come from expansion
5619
5601
if let ExprKind :: MethodCall ( path, recv, args, _call_span) = expr. kind {
5602
+ let method_span = path. ident . span ;
5603
+
5604
+ // Those methods do their own method name checking as they deal with multiple methods.
5605
+ or_fun_call:: check ( cx, expr, method_span, path. ident . name , recv, args, self . msrv ) ;
5606
+ unnecessary_to_owned:: check ( cx, expr, path. ident . name , recv, args, self . msrv ) ;
5607
+
5620
5608
match ( path. ident . name , args) {
5609
+ ( sym:: clone, [ ] ) => {
5610
+ clone_on_ref_ptr:: check ( cx, expr, recv) ;
5611
+ clone_on_copy:: check ( cx, expr, recv) ;
5612
+ } ,
5621
5613
( sym:: expect, [ _] ) => {
5622
5614
unwrap_expect_used:: check (
5623
5615
cx,
@@ -5628,6 +5620,7 @@ impl Methods {
5628
5620
self . allow_expect_in_tests ,
5629
5621
unwrap_expect_used:: Variant :: Expect ,
5630
5622
) ;
5623
+ expect_fun_call:: check ( cx, & self . format_args , expr, method_span, recv, args) ;
5631
5624
} ,
5632
5625
( sym:: expect_err, [ _] ) => {
5633
5626
unwrap_expect_used:: check (
@@ -5640,6 +5633,15 @@ impl Methods {
5640
5633
unwrap_expect_used:: Variant :: Expect ,
5641
5634
) ;
5642
5635
} ,
5636
+ ( sym:: insert_str | sym:: push_str, _) => {
5637
+ single_char_add_str:: check ( cx, expr, recv, args) ;
5638
+ } ,
5639
+ ( sym:: into_iter, [ ] ) => {
5640
+ into_iter_on_ref:: check ( cx, expr, method_span, recv) ;
5641
+ } ,
5642
+ ( sym:: to_string, [ ] ) => {
5643
+ inefficient_to_string:: check ( cx, expr, recv) ;
5644
+ } ,
5643
5645
( sym:: unwrap, [ ] ) => {
5644
5646
unwrap_expect_used:: check (
5645
5647
cx,
0 commit comments