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