@@ -4843,8 +4843,6 @@ impl<'tcx> LateLintPass<'tcx> for Methods {
4843
4843
return ;
4844
4844
}
4845
4845
4846
- self . check_methods ( cx, expr) ;
4847
-
4848
4846
match expr. kind {
4849
4847
ExprKind :: Call ( func, args) => {
4850
4848
from_iter_instead_of_collect:: check ( cx, expr, args, func) ;
@@ -4855,24 +4853,8 @@ impl<'tcx> LateLintPass<'tcx> for Methods {
4855
4853
swap_with_temporary:: check ( cx, expr, func, args) ;
4856
4854
ip_constant:: check ( cx, expr, func, args) ;
4857
4855
} ,
4858
- ExprKind :: MethodCall ( method_call, receiver, args, _) => {
4859
- let method_span = method_call. ident . span ;
4860
- or_fun_call:: check ( cx, expr, method_span, method_call. ident . name , receiver, args, self . msrv ) ;
4861
- expect_fun_call:: check (
4862
- cx,
4863
- & self . format_args ,
4864
- expr,
4865
- method_span,
4866
- method_call. ident . name ,
4867
- receiver,
4868
- args,
4869
- ) ;
4870
- clone_on_copy:: check ( cx, expr, method_call. ident . name , receiver, args) ;
4871
- clone_on_ref_ptr:: check ( cx, expr, method_call. ident . name , receiver, args) ;
4872
- inefficient_to_string:: check ( cx, expr, method_call. ident . name , receiver, args, self . msrv ) ;
4873
- single_char_add_str:: check ( cx, expr, receiver, args) ;
4874
- into_iter_on_ref:: check ( cx, expr, method_span, method_call. ident . name , receiver) ;
4875
- unnecessary_to_owned:: check ( cx, expr, method_call. ident . name , receiver, args, self . msrv ) ;
4856
+ ExprKind :: MethodCall ( ..) => {
4857
+ self . check_methods ( cx, expr) ;
4876
4858
} ,
4877
4859
ExprKind :: Binary ( op, lhs, rhs) if op. node == hir:: BinOpKind :: Eq || op. node == hir:: BinOpKind :: Ne => {
4878
4860
let mut info = BinaryExprInfo {
@@ -5592,7 +5574,17 @@ impl Methods {
5592
5574
}
5593
5575
// Handle method calls whose receiver and arguments may come from expansion
5594
5576
if let ExprKind :: MethodCall ( path, recv, args, _call_span) = expr. kind {
5577
+ let method_span = path. ident . span ;
5578
+
5579
+ // Those methods do their own method name checking as they deal with multiple methods.
5580
+ or_fun_call:: check ( cx, expr, method_span, path. ident . name , recv, args, self . msrv ) ;
5581
+ unnecessary_to_owned:: check ( cx, expr, path. ident . name , recv, args, self . msrv ) ;
5582
+
5595
5583
match ( path. ident . name , args) {
5584
+ ( sym:: clone, [ ] ) => {
5585
+ clone_on_ref_ptr:: check ( cx, expr, recv) ;
5586
+ clone_on_copy:: check ( cx, expr, recv) ;
5587
+ } ,
5596
5588
( sym:: expect, [ _] ) => {
5597
5589
unwrap_expect_used:: check (
5598
5590
cx,
@@ -5603,6 +5595,7 @@ impl Methods {
5603
5595
self . allow_expect_in_tests ,
5604
5596
unwrap_expect_used:: Variant :: Expect ,
5605
5597
) ;
5598
+ expect_fun_call:: check ( cx, & self . format_args , expr, method_span, recv, args) ;
5606
5599
} ,
5607
5600
( sym:: expect_err, [ _] ) => {
5608
5601
unwrap_expect_used:: check (
@@ -5615,6 +5608,15 @@ impl Methods {
5615
5608
unwrap_expect_used:: Variant :: Expect ,
5616
5609
) ;
5617
5610
} ,
5611
+ ( sym:: insert_str | sym:: push_str, _) => {
5612
+ single_char_add_str:: check ( cx, expr, recv, args) ;
5613
+ } ,
5614
+ ( sym:: into_iter, [ ] ) => {
5615
+ into_iter_on_ref:: check ( cx, expr, method_span, recv) ;
5616
+ } ,
5617
+ ( sym:: to_string, [ ] ) => {
5618
+ inefficient_to_string:: check ( cx, expr, recv, self . msrv ) ;
5619
+ } ,
5618
5620
( sym:: unwrap, [ ] ) => {
5619
5621
unwrap_expect_used:: check (
5620
5622
cx,
0 commit comments