@@ -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 {
@@ -5571,8 +5553,18 @@ impl Methods {
55715553 }
55725554 // Handle method calls whose receiver and arguments may come from expansion
55735555 if let ExprKind :: MethodCall ( path, recv, args, _call_span) = expr. kind {
5556+ let method_span = path. ident . span ;
5557+
5558+ // Those methods do their own method name checking as they deal with multiple methods.
5559+ or_fun_call:: check ( cx, expr, method_span, path. ident . name , recv, args, self . msrv ) ;
5560+ unnecessary_to_owned:: check ( cx, expr, path. ident . name , recv, args, self . msrv ) ;
5561+
55745562 match ( path. ident . name , args) {
5575- ( sym:: expect, [ _] ) => {
5563+ ( sym:: clone, [ ] ) => {
5564+ clone_on_ref_ptr:: check ( cx, expr, recv) ;
5565+ clone_on_copy:: check ( cx, expr, recv) ;
5566+ } ,
5567+ ( sym:: expect, [ arg] ) => {
55765568 unwrap_expect_used:: check (
55775569 cx,
55785570 expr,
@@ -5582,6 +5574,7 @@ impl Methods {
55825574 self . allow_expect_in_tests ,
55835575 unwrap_expect_used:: Variant :: Expect ,
55845576 ) ;
5577+ expect_fun_call:: check ( cx, & self . format_args , expr, method_span, recv, arg) ;
55855578 } ,
55865579 ( sym:: expect_err, [ _] ) => {
55875580 unwrap_expect_used:: check (
@@ -5594,6 +5587,15 @@ impl Methods {
55945587 unwrap_expect_used:: Variant :: Expect ,
55955588 ) ;
55965589 } ,
5590+ ( sym:: insert_str | sym:: push_str, _) => {
5591+ single_char_add_str:: check ( cx, expr, recv, args) ;
5592+ } ,
5593+ ( sym:: into_iter, [ ] ) => {
5594+ into_iter_on_ref:: check ( cx, expr, method_span, recv) ;
5595+ } ,
5596+ ( sym:: to_string, [ ] ) => {
5597+ inefficient_to_string:: check ( cx, expr, recv, self . msrv ) ;
5598+ } ,
55975599 ( sym:: unwrap, [ ] ) => {
55985600 unwrap_expect_used:: check (
55995601 cx,
0 commit comments