@@ -39,21 +39,28 @@ impl<'tcx> LateLintPass<'tcx> for UnnecessaryMutPassed {
3939 arguments,
4040 cx. typeck_results ( ) . expr_ty ( fn_expr) ,
4141 & rustc_hir_pretty:: to_string ( rustc_hir_pretty:: NO_ANN , |s| s. print_qpath ( path, false ) ) ,
42+ "function" ,
4243 ) ;
4344 }
4445 } ,
4546 ExprKind :: MethodCall ( ref path, _, ref arguments, _) => {
4647 let def_id = cx. typeck_results ( ) . type_dependent_def_id ( e. hir_id ) . unwrap ( ) ;
4748 let substs = cx. typeck_results ( ) . node_substs ( e. hir_id ) ;
4849 let method_type = cx. tcx . type_of ( def_id) . subst ( cx. tcx , substs) ;
49- check_arguments ( cx, arguments, method_type, & path. ident . as_str ( ) )
50+ check_arguments ( cx, arguments, method_type, & path. ident . as_str ( ) , "method" )
5051 } ,
5152 _ => ( ) ,
5253 }
5354 }
5455}
5556
56- fn check_arguments < ' tcx > ( cx : & LateContext < ' tcx > , arguments : & [ Expr < ' _ > ] , type_definition : Ty < ' tcx > , name : & str ) {
57+ fn check_arguments < ' tcx > (
58+ cx : & LateContext < ' tcx > ,
59+ arguments : & [ Expr < ' _ > ] ,
60+ type_definition : Ty < ' tcx > ,
61+ name : & str ,
62+ fn_kind : & str ,
63+ ) {
5764 match type_definition. kind {
5865 ty:: FnDef ( ..) | ty:: FnPtr ( _) => {
5966 let parameters = type_definition. fn_sig ( cx. tcx ) . skip_binder ( ) . inputs ( ) ;
@@ -68,7 +75,7 @@ fn check_arguments<'tcx>(cx: &LateContext<'tcx>, arguments: &[Expr<'_>], type_de
6875 cx,
6976 UNNECESSARY_MUT_PASSED ,
7077 argument. span ,
71- & format ! ( "The function/method `{}` doesn't need a mutable reference" , name) ,
78+ & format ! ( "the {} `{}` doesn't need a mutable reference" , fn_kind , name) ,
7279 ) ;
7380 }
7481 } ,
0 commit comments