Skip to content

Commit

Permalink
Avoid unnecessary mutability for UnusedResults.
Browse files Browse the repository at this point in the history
  • Loading branch information
Ms2ger committed Feb 28, 2015
1 parent 2a37f7f commit f38b83b
Showing 1 changed file with 7 additions and 6 deletions.
13 changes: 7 additions & 6 deletions src/librustc_lint/builtin.rs
Expand Up @@ -741,23 +741,24 @@ impl LintPass for UnusedResults {
}

let t = ty::expr_ty(cx.tcx, expr);
let mut warned = false;
match t.sty {
let warned = match t.sty {
ty::ty_tup(ref tys) if tys.is_empty() => return,
ty::ty_bool => return,
ty::ty_struct(did, _) |
ty::ty_enum(did, _) => {
if ast_util::is_local(did) {
if let ast_map::NodeItem(it) = cx.tcx.map.get(did.node) {
warned |= check_must_use(cx, &it.attrs, s.span);
check_must_use(cx, &it.attrs, s.span)
} else {
false
}
} else {
let attrs = csearch::get_item_attrs(&cx.sess().cstore, did);
warned |= check_must_use(cx, &attrs[..], s.span);
check_must_use(cx, &attrs[..], s.span)
}
}
_ => {}
}
_ => false,
};
if !warned {
cx.span_lint(UNUSED_RESULTS, s.span, "unused result");
}
Expand Down

0 comments on commit f38b83b

Please sign in to comment.