File tree Expand file tree Collapse file tree 2 files changed +12
-12
lines changed Expand file tree Collapse file tree 2 files changed +12
-12
lines changed Original file line number Diff line number Diff line change @@ -85,20 +85,12 @@ impl LintPass for UnusedMut {
8585}
8686
8787impl < ' a , ' tcx > LateLintPass < ' a , ' tcx > for UnusedMut {
88- fn check_expr ( & mut self , cx : & LateContext , e : & hir:: Expr ) {
89- if let hir:: ExprMatch ( _, ref arms, _) = e. node {
90- for a in arms {
91- self . check_unused_mut_pat ( cx, & a. pats )
92- }
93- }
88+ fn check_arm ( & mut self , cx : & LateContext , a : & hir:: Arm ) {
89+ self . check_unused_mut_pat ( cx, & a. pats )
9490 }
9591
96- fn check_stmt ( & mut self , cx : & LateContext , s : & hir:: Stmt ) {
97- if let hir:: StmtDecl ( ref d, _) = s. node {
98- if let hir:: DeclLocal ( ref l) = d. node {
99- self . check_unused_mut_pat ( cx, slice:: ref_slice ( & l. pat ) ) ;
100- }
101- }
92+ fn check_local ( & mut self , cx : & LateContext , l : & hir:: Local ) {
93+ self . check_unused_mut_pat ( cx, slice:: ref_slice ( & l. pat ) ) ;
10294 }
10395
10496 fn check_fn ( & mut self ,
Original file line number Diff line number Diff line change @@ -110,3 +110,11 @@ fn foo(mut a: isize) {
110110 let mut a = 3 ;
111111 let mut b = vec ! [ 2 ] ;
112112}
113+
114+ // make sure the lint attribute can be turned off on let statements
115+ #[ deny( unused_mut) ]
116+ fn bar ( ) {
117+ #[ allow( unused_mut) ]
118+ let mut a = 3 ;
119+ let mut b = vec ! [ 2 ] ; //~ ERROR: variable does not need to be mutable
120+ }
You can’t perform that action at this time.
0 commit comments