@@ -4842,8 +4842,6 @@ impl<'tcx> LateLintPass<'tcx> for Methods {
48424842 return ;
48434843 }
48444844
4845- self . check_methods ( cx, expr) ;
4846-
48474845 match expr. kind {
48484846 ExprKind :: Call ( func, args) => {
48494847 from_iter_instead_of_collect:: check ( cx, expr, args, func) ;
@@ -4854,24 +4852,8 @@ impl<'tcx> LateLintPass<'tcx> for Methods {
48544852 swap_with_temporary:: check ( cx, expr, func, args) ;
48554853 ip_constant:: check ( cx, expr, func, args) ;
48564854 } ,
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) ;
48754857 } ,
48764858 ExprKind :: Binary ( op, lhs, rhs) if op. node == hir:: BinOpKind :: Eq || op. node == hir:: BinOpKind :: Ne => {
48774859 let mut info = BinaryExprInfo {
@@ -5566,8 +5548,18 @@ impl Methods {
55665548 }
55675549 // Handle method calls whose receiver and arguments may come from expansion
55685550 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+
55695557 match ( path. ident . name , args) {
5570- ( sym:: expect, [ _] ) => {
5558+ ( sym:: clone, [ ] ) => {
5559+ clone_on_ref_ptr:: check ( cx, expr, recv) ;
5560+ clone_on_copy:: check ( cx, expr, recv) ;
5561+ } ,
5562+ ( sym:: expect, [ arg] ) => {
55715563 unwrap_expect_used:: check (
55725564 cx,
55735565 expr,
@@ -5577,6 +5569,7 @@ impl Methods {
55775569 self . allow_expect_in_tests ,
55785570 unwrap_expect_used:: Variant :: Expect ,
55795571 ) ;
5572+ expect_fun_call:: check ( cx, & self . format_args , expr, method_span, recv, arg) ;
55805573 } ,
55815574 ( sym:: expect_err, [ _] ) => {
55825575 unwrap_expect_used:: check (
@@ -5589,6 +5582,15 @@ impl Methods {
55895582 unwrap_expect_used:: Variant :: Expect ,
55905583 ) ;
55915584 } ,
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+ } ,
55925594 ( sym:: unwrap, [ ] ) => {
55935595 unwrap_expect_used:: check (
55945596 cx,
0 commit comments