Skip to content

Fix FP for let_unit_value when await used #10439

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Merged
merged 1 commit into from
Mar 4, 2023
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
6 changes: 5 additions & 1 deletion clippy_lints/src/unit_types/let_unit_value.rs
Original file line number Diff line number Diff line change
Expand Up @@ -5,7 +5,7 @@ use clippy_utils::visitors::{for_each_local_assignment, for_each_value_source};
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;
Expand Down Expand Up @@ -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,
Expand Down
4 changes: 4 additions & 0 deletions tests/ui/let_unit.fixed
Original file line number Diff line number Diff line change
Expand Up @@ -175,3 +175,7 @@ fn attributes() {
#[expect(clippy::let_unit_value)]
let _ = f();
}

async fn issue10433() {
let _pending: () = std::future::pending().await;
}
4 changes: 4 additions & 0 deletions tests/ui/let_unit.rs
Original file line number Diff line number Diff line change
Expand Up @@ -175,3 +175,7 @@ fn attributes() {
#[expect(clippy::let_unit_value)]
let _ = f();
}

async fn issue10433() {
let _pending: () = std::future::pending().await;
}