Skip to content

Commit 26488b7

Browse files
committed
librustc: Don't emit unused mut lint twice.
1 parent f5e64ae commit 26488b7

File tree

1 file changed

+17
-24
lines changed

1 file changed

+17
-24
lines changed

src/librustc/middle/lint.rs

Lines changed: 17 additions & 24 deletions
Original file line numberDiff line numberDiff line change
@@ -813,32 +813,25 @@ fn check_unused_unsafe(cx: &Context, e: &ast::Expr) {
813813
}
814814

815815
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);
836831
}
837-
_ => {}
838832
}
839-
840-
true
841-
};
833+
_ => ()
834+
}
842835
}
843836

844837
fn check_unnecessary_allocation(cx: &Context, e: &ast::Expr) {

0 commit comments

Comments
 (0)