@@ -39,21 +39,28 @@ impl<'tcx> LateLintPass<'tcx> for UnnecessaryMutPassed {
39
39
arguments,
40
40
cx. typeck_results ( ) . expr_ty ( fn_expr) ,
41
41
& rustc_hir_pretty:: to_string ( rustc_hir_pretty:: NO_ANN , |s| s. print_qpath ( path, false ) ) ,
42
+ "function" ,
42
43
) ;
43
44
}
44
45
} ,
45
46
ExprKind :: MethodCall ( ref path, _, ref arguments, _) => {
46
47
let def_id = cx. typeck_results ( ) . type_dependent_def_id ( e. hir_id ) . unwrap ( ) ;
47
48
let substs = cx. typeck_results ( ) . node_substs ( e. hir_id ) ;
48
49
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" )
50
51
} ,
51
52
_ => ( ) ,
52
53
}
53
54
}
54
55
}
55
56
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
+ ) {
57
64
match type_definition. kind {
58
65
ty:: FnDef ( ..) | ty:: FnPtr ( _) => {
59
66
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
68
75
cx,
69
76
UNNECESSARY_MUT_PASSED ,
70
77
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) ,
72
79
) ;
73
80
}
74
81
} ,
0 commit comments