@@ -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, self . msrv ) ;
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, self . msrv ) ;
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 {
@@ -5566,7 +5548,17 @@ impl Methods {
5566
5548
}
5567
5549
// Handle method calls whose receiver and arguments may come from expansion
5568
5550
if let ExprKind :: MethodCall ( path, recv, args, _call_span) = expr. kind {
5551
+ let method_span = path. ident . span ;
5552
+
5553
+ // Those methods do their own method name checking as they deal with multiple methods.
5554
+ or_fun_call:: check ( cx, expr, method_span, path. ident . name , recv, args, self . msrv ) ;
5555
+ unnecessary_to_owned:: check ( cx, expr, path. ident . name , recv, args, self . msrv ) ;
5556
+
5569
5557
match ( path. ident . name , args) {
5558
+ ( sym:: clone, [ ] ) => {
5559
+ clone_on_ref_ptr:: check ( cx, expr, recv) ;
5560
+ clone_on_copy:: check ( cx, expr, recv) ;
5561
+ } ,
5570
5562
( sym:: expect, [ _] ) => {
5571
5563
unwrap_expect_used:: check (
5572
5564
cx,
@@ -5577,6 +5569,7 @@ impl Methods {
5577
5569
self . allow_expect_in_tests ,
5578
5570
unwrap_expect_used:: Variant :: Expect ,
5579
5571
) ;
5572
+ expect_fun_call:: check ( cx, & self . format_args , expr, method_span, recv, args) ;
5580
5573
} ,
5581
5574
( sym:: expect_err, [ _] ) => {
5582
5575
unwrap_expect_used:: check (
@@ -5589,6 +5582,15 @@ impl Methods {
5589
5582
unwrap_expect_used:: Variant :: Expect ,
5590
5583
) ;
5591
5584
} ,
5585
+ ( sym:: insert_str | sym:: push_str, _) => {
5586
+ single_char_add_str:: check ( cx, expr, recv, args) ;
5587
+ } ,
5588
+ ( sym:: into_iter, [ ] ) => {
5589
+ into_iter_on_ref:: check ( cx, expr, method_span, recv) ;
5590
+ } ,
5591
+ ( sym:: to_string, [ ] ) => {
5592
+ inefficient_to_string:: check ( cx, expr, recv, self . msrv ) ;
5593
+ } ,
5592
5594
( sym:: unwrap, [ ] ) => {
5593
5595
unwrap_expect_used:: check (
5594
5596
cx,
0 commit comments