mirror of
https://github.com/rust-lang/rust-clippy
synced 2024-11-10 23:24:24 +00:00
Fix yet another FP in USELESS_LET_IF_SEQ
The block expression before the assignment must be `None`.
This commit is contained in:
parent
c5affa2efc
commit
ce2b96abe9
2 changed files with 10 additions and 0 deletions
|
@ -150,6 +150,7 @@ impl<'a, 'tcx, 'v> hir::intravisit::Visitor<'v> for UsedVisitor<'a, 'tcx> {
|
|||
|
||||
fn check_assign<'e>(cx: &LateContext, decl: hir::def_id::DefId, block: &'e hir::Block) -> Option<&'e hir::Expr> {
|
||||
if_let_chain! {[
|
||||
block.expr.is_none(),
|
||||
let Some(expr) = block.stmts.iter().last(),
|
||||
let hir::StmtSemi(ref expr, _) = expr.node,
|
||||
let hir::ExprAssign(ref var, ref value) = expr.node,
|
||||
|
|
|
@ -98,6 +98,15 @@ fn main() {
|
|||
toto = 2;
|
||||
}
|
||||
|
||||
// found in libcore, the inner if is not a statement but the block's expr
|
||||
let mut ch = b'x';
|
||||
if f() {
|
||||
ch = b'*';
|
||||
if f() {
|
||||
ch = b'?';
|
||||
}
|
||||
}
|
||||
|
||||
// baz needs to be mut
|
||||
let mut baz = 0;
|
||||
//~^ ERROR `if _ { .. } else { .. }` is an expression
|
||||
|
|
Loading…
Reference in a new issue