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