File tree 2 files changed +12
-12
lines changed
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 {
85
85
}
86
86
87
87
impl < ' 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 )
94
90
}
95
91
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 ) ) ;
102
94
}
103
95
104
96
fn check_fn ( & mut self ,
Original file line number Diff line number Diff line change @@ -110,3 +110,11 @@ fn foo(mut a: isize) {
110
110
let mut a = 3 ;
111
111
let mut b = vec ! [ 2 ] ;
112
112
}
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