@@ -813,32 +813,25 @@ fn check_unused_unsafe(cx: &Context, e: &ast::Expr) {
813
813
}
814
814
815
815
fn check_unused_mut_pat ( cx : & Context , p : @ast:: Pat ) {
816
- fn check_unused_mut_pat_inner( cx : & Context , p : @ast:: Pat ) {
817
- let mut used = false ;
818
- let mut bindings = 0 ;
819
- do pat_util:: pat_bindings ( cx. tcx . def_map , p) |_, id, _, _| {
820
- used = used || cx. tcx . used_mut_nodes . contains ( & id) ;
821
- bindings += 1 ;
822
- }
823
- if !used {
824
- let msg = if bindings == 1 {
825
- "variable does not need to be mutable"
826
- } else {
827
- "variables do not need to be mutable"
828
- } ;
829
- cx. span_lint ( unused_mut, p. span , msg) ;
830
- }
831
- }
832
- do ast_util:: walk_pat ( p) |pat| {
833
- match pat. node {
834
- ast:: PatIdent ( ast:: BindByValue ( ast:: MutMutable ) , _, _) => {
835
- check_unused_mut_pat_inner ( cx, pat) ;
816
+ match p. node {
817
+ ast:: PatIdent ( ast:: BindByValue ( ast:: MutMutable ) , _, _) => {
818
+ let mut used = false ;
819
+ let mut bindings = 0 ;
820
+ do pat_util:: pat_bindings ( cx. tcx . def_map , p) |_, id, _, _| {
821
+ used = used || cx. tcx . used_mut_nodes . contains ( & id) ;
822
+ bindings += 1 ;
823
+ }
824
+ if !used {
825
+ let msg = if bindings == 1 {
826
+ "variable does not need to be mutable"
827
+ } else {
828
+ "variables do not need to be mutable"
829
+ } ;
830
+ cx. span_lint ( unused_mut, p. span , msg) ;
836
831
}
837
- _ => { }
838
832
}
839
-
840
- true
841
- } ;
833
+ _ => ( )
834
+ }
842
835
}
843
836
844
837
fn check_unnecessary_allocation( cx: & Context , e: & ast:: Expr ) {
0 commit comments