mirror of
https://github.com/rust-lang/rust-clippy
synced 2024-11-10 23:24:24 +00:00
useless_let_if_seq handle interior mutability
This commit is contained in:
parent
6ae46a8c4d
commit
2bbe8be8d0
2 changed files with 16 additions and 0 deletions
|
@ -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_) {
|
||||
|
|
|
@ -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());
|
||||
|
||||
}
|
||||
|
|
Loading…
Reference in a new issue