@@ -53,21 +53,24 @@ impl LateLintPass for UnnecessaryMutPassed {
53
53
}
54
54
55
55
fn check_arguments ( cx : & LateContext , arguments : & [ P < Expr > ] , type_definition : & TyS , name : & str ) {
56
- if let TypeVariants :: TyBareFn ( _, ref fn_type) = type_definition. sty {
57
- let parameters = & fn_type. sig . skip_binder ( ) . inputs ;
58
- for ( argument, parameter) in arguments. iter ( ) . zip ( parameters. iter ( ) ) {
59
- match parameter. sty {
60
- TypeVariants :: TyRef ( _, TypeAndMut { mutbl : MutImmutable , ..} ) |
61
- TypeVariants :: TyRawPtr ( TypeAndMut { mutbl : MutImmutable , ..} ) => {
62
- if let ExprAddrOf ( MutMutable , _) = argument. node {
63
- span_lint ( cx,
64
- UNNECESSARY_MUT_PASSED ,
65
- argument. span ,
66
- & format ! ( "The function/method \" {}\" doesn't need a mutable reference" , name) ) ;
56
+ match type_definition. sty {
57
+ TypeVariants :: TyFnDef ( _, _, ref fn_type) | TypeVariants :: TyFnPtr ( ref fn_type) => {
58
+ let parameters = & fn_type. sig . skip_binder ( ) . inputs ;
59
+ for ( argument, parameter) in arguments. iter ( ) . zip ( parameters. iter ( ) ) {
60
+ match parameter. sty {
61
+ TypeVariants :: TyRef ( _, TypeAndMut { mutbl : MutImmutable , ..} ) |
62
+ TypeVariants :: TyRawPtr ( TypeAndMut { mutbl : MutImmutable , ..} ) => {
63
+ if let ExprAddrOf ( MutMutable , _) = argument. node {
64
+ span_lint ( cx,
65
+ UNNECESSARY_MUT_PASSED ,
66
+ argument. span ,
67
+ & format ! ( "The function/method \" {}\" doesn't need a mutable reference" , name) ) ;
68
+ }
67
69
}
70
+ _ => { }
68
71
}
69
- _ => { }
70
72
}
71
73
}
74
+ _ => ( ) ,
72
75
}
73
76
}
0 commit comments