fix: unnecessary_lazy_evaluations suggests wrongly for async closure (#14644)
Closes rust-lang/rust-clippy#14578 changelog: [`unnecessary_lazy_evaluations`] fix wrong suggestions for async closure
This commit is contained in:
commit
a49ea2d63d
3 changed files with 14 additions and 1 deletions
|
|
@ -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;
|
||||
|
|
|
|||
|
|
@ -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());
|
||||
}
|
||||
|
|
|
|||
|
|
@ -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());
|
||||
}
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue