Fix FP for let_unit_value when await used

This commit is contained in:
Takayuki Nakata 2023-03-03 22:41:39 +09:00
parent 8b65632b6e
commit 027f19c8b9
3 changed files with 13 additions and 1 deletions

View File

@ -5,7 +5,7 @@
use core::ops::ControlFlow;
use rustc_errors::Applicability;
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_middle::lint::in_external_macro;
use rustc_middle::ty;
@ -41,6 +41,10 @@ pub(super) fn check<'tcx>(cx: &LateContext<'tcx>, local: &'tcx Local<'_>) {
);
}
} else {
if let ExprKind::Match(_, _, MatchSource::AwaitDesugar) = init.kind {
return
}
span_lint_and_then(
cx,
LET_UNIT_VALUE,

View File

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

View File

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