about summary refs log tree commit diff
diff options
context:
space:
mode:
-rw-r--r--clippy_lints/src/utils/author.rs2
-rw-r--r--tests/ui/author/blocks.stdout1
-rw-r--r--tests/ui/author/for_loop.stdout2
-rw-r--r--tests/ui/author/if.stdout2
4 files changed, 7 insertions, 0 deletions
diff --git a/clippy_lints/src/utils/author.rs b/clippy_lints/src/utils/author.rs
index d59f96b4bee..c1e7fd7fe95 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 4e3cde498af..854bc28083a 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 771f4f128f5..f1b4d4e096e 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 1b9ed366c19..502b38545b8 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