useless_let_if_seq handle interior mutability

This commit is contained in:
Josh Mcguigan 2019-04-25 19:07:01 -07:00
parent 6ae46a8c4d
commit 2bbe8be8d0
2 changed files with 16 additions and 0 deletions

View file

@ -71,6 +71,13 @@ impl<'a, 'tcx> LateLintPass<'a, 'tcx> for LetIfSeq {
then {
let span = stmt.span.to(if_.span);
let has_interior_mutability = !cx.tables.node_type(canonical_id).is_freeze(
cx.tcx,
cx.param_env,
span
);
if has_interior_mutability { return; }
let (default_multi_stmts, default) = if let Some(ref else_) = *else_ {
if let hir::ExprKind::Block(ref else_, _) = else_.node {
if let Some(default) = check_assign(cx, canonical_id, else_) {

View file

@ -108,4 +108,13 @@ fn main() {
}
baz = 1337;
// issue 3043 - types with interior mutability should not trigger this lint
use std::cell::Cell;
let mut val = Cell::new(1);
if true {
val = Cell::new(2);
}
println!("{}", val.get());
}