about summary refs log tree commit diff
diff options
context:
space:
mode:
-rw-r--r--clippy_lints/src/methods/unnecessary_lazy_eval.rs7
-rw-r--r--tests/ui/unnecessary_lazy_eval.fixed4
-rw-r--r--tests/ui/unnecessary_lazy_eval.rs4
3 files changed, 14 insertions, 1 deletions
diff --git a/clippy_lints/src/methods/unnecessary_lazy_eval.rs b/clippy_lints/src/methods/unnecessary_lazy_eval.rs
index e3596cf6a60..71e606add52 100644
--- a/clippy_lints/src/methods/unnecessary_lazy_eval.rs
+++ b/clippy_lints/src/methods/unnecessary_lazy_eval.rs
@@ -24,7 +24,12 @@ pub(super) fn check<'tcx>(
     let is_bool = cx.typeck_results().expr_ty(recv).is_bool();
 
     if (is_option || is_result || is_bool)
-        && let hir::ExprKind::Closure(&hir::Closure { body, fn_decl, .. }) = arg.kind
+        && let hir::ExprKind::Closure(&hir::Closure {
+            body,
+            fn_decl,
+            kind: hir::ClosureKind::Closure,
+            ..
+        }) = arg.kind
     {
         let body = cx.tcx.hir_body(body);
         let body_expr = &body.value;
diff --git a/tests/ui/unnecessary_lazy_eval.fixed b/tests/ui/unnecessary_lazy_eval.fixed
index 9a329081638..409a8efbfeb 100644
--- a/tests/ui/unnecessary_lazy_eval.fixed
+++ b/tests/ui/unnecessary_lazy_eval.fixed
@@ -321,3 +321,7 @@ fn panicky_arithmetic_ops(x: usize, y: isize) {
     let _x = false.then_some(f1 + f2);
     //~^ unnecessary_lazy_evaluations
 }
+
+fn issue14578() {
+    let _: Box<dyn std::future::Future<Output = i32>> = Box::new(true.then(async || 42).unwrap());
+}
diff --git a/tests/ui/unnecessary_lazy_eval.rs b/tests/ui/unnecessary_lazy_eval.rs
index 2d05ef5c291..54735023a93 100644
--- a/tests/ui/unnecessary_lazy_eval.rs
+++ b/tests/ui/unnecessary_lazy_eval.rs
@@ -321,3 +321,7 @@ fn panicky_arithmetic_ops(x: usize, y: isize) {
     let _x = false.then(|| f1 + f2);
     //~^ unnecessary_lazy_evaluations
 }
+
+fn issue14578() {
+    let _: Box<dyn std::future::Future<Output = i32>> = Box::new(true.then(async || 42).unwrap());
+}