diff --git a/clippy_lints/src/let_if_seq.rs b/clippy_lints/src/let_if_seq.rs index fc858464fc4..412571cebf2 100644 --- a/clippy_lints/src/let_if_seq.rs +++ b/clippy_lints/src/let_if_seq.rs @@ -69,9 +69,9 @@ impl<'a, 'tcx> LateLintPass<'a, 'tcx> for LetIfSeq { let hir::StmtExpr(ref if_, _) = expr.node, let hir::ExprIf(ref cond, ref then, ref else_) = if_.node, !used_in_expr(cx, def_id, cond), - !used_in_expr(cx, def_id, &*then), let hir::ExprBlock(ref then) = then.node, let Some(value) = check_assign(cx, def_id, &*then), + !used_in_expr(cx, def_id, value), ], { let span = Span { lo: stmt.span.lo, hi: if_.span.hi, ctxt: NO_EXPANSION }; diff --git a/clippy_lints/src/needless_bool.rs b/clippy_lints/src/needless_bool.rs index c546cf5bd0e..53b26fc1276 100644 --- a/clippy_lints/src/needless_bool.rs +++ b/clippy_lints/src/needless_bool.rs @@ -76,7 +76,8 @@ impl<'a, 'tcx> LateLintPass<'a, 'tcx> for NeedlessBool { "this if-then-else expression returns a bool literal", |db| { db.span_suggestion(e.span, "you can reduce it to", hint); }); }; - match (fetch_bool_expr(&**then_block), fetch_bool_expr(else_expr)) { + if let ExprBlock(ref then_block) = then_block.node { + match (fetch_bool_block(then_block), fetch_bool_expr(else_expr)) { (RetBool(true), RetBool(true)) | (Bool(true), Bool(true)) => { span_lint(cx, @@ -97,6 +98,9 @@ impl<'a, 'tcx> LateLintPass<'a, 'tcx> for NeedlessBool { (Bool(false), Bool(true)) => reduce(false, true), _ => (), } + } else { + panic!("IfExpr 'then' node is not an ExprBlock"); + } } } }