Auto merge of #10439 - giraffate:fix_fp_for_let_unit_value, r=Jarcho

Fix FP for `let_unit_value` when `await` used

Fix https://github.com/rust-lang/rust-clippy/issues/10433

changelog: Fix FP for `let_unit_value` when `await` used
This commit is contained in:
bors 2023-03-04 19:42:26 +00:00
commit 2500f960fc
3 changed files with 13 additions and 1 deletions

View file

@ -5,7 +5,7 @@ use clippy_utils::visitors::{for_each_local_assignment, for_each_value_source};
use core::ops::ControlFlow; use core::ops::ControlFlow;
use rustc_errors::Applicability; use rustc_errors::Applicability;
use rustc_hir::def::{DefKind, Res}; use rustc_hir::def::{DefKind, Res};
use rustc_hir::{Expr, ExprKind, HirId, HirIdSet, Local, Node, PatKind, QPath, TyKind}; use rustc_hir::{Expr, ExprKind, HirId, HirIdSet, Local, MatchSource, Node, PatKind, QPath, TyKind};
use rustc_lint::{LateContext, LintContext}; use rustc_lint::{LateContext, LintContext};
use rustc_middle::lint::in_external_macro; use rustc_middle::lint::in_external_macro;
use rustc_middle::ty; use rustc_middle::ty;
@ -41,6 +41,10 @@ pub(super) fn check<'tcx>(cx: &LateContext<'tcx>, local: &'tcx Local<'_>) {
); );
} }
} else { } else {
if let ExprKind::Match(_, _, MatchSource::AwaitDesugar) = init.kind {
return
}
span_lint_and_then( span_lint_and_then(
cx, cx,
LET_UNIT_VALUE, LET_UNIT_VALUE,

View file

@ -175,3 +175,7 @@ fn attributes() {
#[expect(clippy::let_unit_value)] #[expect(clippy::let_unit_value)]
let _ = f(); let _ = f();
} }
async fn issue10433() {
let _pending: () = std::future::pending().await;
}

View file

@ -175,3 +175,7 @@ fn attributes() {
#[expect(clippy::let_unit_value)] #[expect(clippy::let_unit_value)]
let _ = f(); let _ = f();
} }
async fn issue10433() {
let _pending: () = std::future::pending().await;
}