@@ -53,21 +53,24 @@ impl LateLintPass for UnnecessaryMutPassed {
5353}
5454
5555fn 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+ }
6769 }
70+ _ => { }
6871 }
69- _ => { }
7072 }
7173 }
74+ _ => ( ) ,
7275 }
7376}
0 commit comments