diff --git a/clippy_lints/src/utils/author.rs b/clippy_lints/src/utils/author.rs index d59f96b4b..c1e7fd7fe 100644 --- a/clippy_lints/src/utils/author.rs +++ b/clippy_lints/src/utils/author.rs @@ -554,6 +554,8 @@ impl<'tcx> Visitor<'tcx> for PrintVisitor { self.current = self.next("trailing_expr"); println!(" if let Some({}) = &{}.expr;", self.current, block_name); self.visit_expr(expr); + } else { + println!(" if {}.expr.is_none();", block_name); } } diff --git a/tests/ui/author/blocks.stdout b/tests/ui/author/blocks.stdout index 4e3cde498..854bc2808 100644 --- a/tests/ui/author/blocks.stdout +++ b/tests/ui/author/blocks.stdout @@ -11,6 +11,7 @@ if_chain! { if let ExprKind::Unary(UnOp::Neg, ref inner) = e.kind; if let ExprKind::Path(ref path) = inner.kind; if match_qpath(path, &["x"]); + if block.expr.is_none(); then { // report your lint here } diff --git a/tests/ui/author/for_loop.stdout b/tests/ui/author/for_loop.stdout index 771f4f128..f1b4d4e09 100644 --- a/tests/ui/author/for_loop.stdout +++ b/tests/ui/author/for_loop.stdout @@ -54,6 +54,8 @@ if_chain! { if match_qpath(path9, &["y"]); if let PatKind::Binding(BindingAnnotation::Unannotated, _, name2, None) = local2.pat.kind; if name2.as_str() == "z"; + if block.expr.is_none(); + if body.expr.is_none(); if let PatKind::Binding(BindingAnnotation::Mutable, _, name3, None) = arms[0].pat.kind; if name3.as_str() == "iter"; then { diff --git a/tests/ui/author/if.stdout b/tests/ui/author/if.stdout index 1b9ed366c..502b38545 100644 --- a/tests/ui/author/if.stdout +++ b/tests/ui/author/if.stdout @@ -11,6 +11,7 @@ if_chain! { if let LitKind::Int(2, _) = lit.node; if let ExprKind::Lit(ref lit1) = right.kind; if let LitKind::Int(2, _) = lit1.node; + if block.expr.is_none(); if let ExprKind::Lit(ref lit2) = cond.kind; if let LitKind::Bool(true) = lit2.node; if let ExprKind::Block(ref block1) = then.kind; @@ -22,6 +23,7 @@ if_chain! { if let LitKind::Int(1, _) = lit3.node; if let ExprKind::Lit(ref lit4) = right1.kind; if let LitKind::Int(1, _) = lit4.node; + if block1.expr.is_none(); if let PatKind::Wild = local.pat.kind; then { // report your lint here