@@ -2,7 +2,7 @@ use clippy_utils::diagnostics::span_lint_and_then;
22use  clippy_utils:: ty:: is_type_diagnostic_item; 
33use  clippy_utils:: { is_expr_untyped_identity_function,  is_mutable,  is_trait_method,  path_to_local} ; 
44use  rustc_errors:: Applicability ; 
5- use  rustc_hir:: { self  as  hir,  Node ,  PatKind } ; 
5+ use  rustc_hir:: { self  as  hir,  ExprKind ,   Node ,  PatKind } ; 
66use  rustc_lint:: LateContext ; 
77use  rustc_span:: { Span ,  Symbol ,  sym} ; 
88
@@ -39,7 +39,13 @@ pub(super) fn check(
3939            } 
4040        } 
4141
42-         let  method_requiring_mut = String :: from ( "random_method" ) ;  // TODO 
42+         let  method_requiring_mut = if  let  Node :: Expr ( expr)  = cx. tcx . parent_hir_node ( expr. hir_id ) 
43+             && let  ExprKind :: MethodCall ( method,  ..)  = expr. kind 
44+         { 
45+             Some ( method. ident ) 
46+         }  else  { 
47+             None 
48+         } ; 
4349
4450        span_lint_and_then ( 
4551            cx, 
@@ -57,10 +63,14 @@ pub(super) fn check(
5763                    } , 
5864                ) ; 
5965                if  !apply { 
60-                     diag. span_note ( 
61-                         caller. span , 
62-                         format ! ( "this must be made mutable to use `{method_requiring_mut}`" ) , 
63-                     ) ; 
66+                     if  let  Some ( method_requiring_mut)  = method_requiring_mut { 
67+                         diag. span_note ( 
68+                             caller. span , 
69+                             format ! ( "this must be made mutable to use `{method_requiring_mut}`" ) , 
70+                         ) ; 
71+                     }  else  { 
72+                         diag. span_note ( caller. span ,  "this must be made mutable" . to_string ( ) ) ; 
73+                     } 
6474                } 
6575            } , 
6676        ) ; 
0 commit comments