Skip to content

Commit 2500f96

Browse files
committed
Auto merge of #10439 - giraffate:fix_fp_for_let_unit_value, r=Jarcho
Fix FP for `let_unit_value` when `await` used Fix #10433 changelog: Fix FP for `let_unit_value` when `await` used
2 parents 308d680 + 027f19c commit 2500f96

File tree

3 files changed

+13
-1
lines changed

3 files changed

+13
-1
lines changed

clippy_lints/src/unit_types/let_unit_value.rs

Lines changed: 5 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -5,7 +5,7 @@ use clippy_utils::visitors::{for_each_local_assignment, for_each_value_source};
55
use core::ops::ControlFlow;
66
use rustc_errors::Applicability;
77
use rustc_hir::def::{DefKind, Res};
8-
use rustc_hir::{Expr, ExprKind, HirId, HirIdSet, Local, Node, PatKind, QPath, TyKind};
8+
use rustc_hir::{Expr, ExprKind, HirId, HirIdSet, Local, MatchSource, Node, PatKind, QPath, TyKind};
99
use rustc_lint::{LateContext, LintContext};
1010
use rustc_middle::lint::in_external_macro;
1111
use rustc_middle::ty;
@@ -41,6 +41,10 @@ pub(super) fn check<'tcx>(cx: &LateContext<'tcx>, local: &'tcx Local<'_>) {
4141
);
4242
}
4343
} else {
44+
if let ExprKind::Match(_, _, MatchSource::AwaitDesugar) = init.kind {
45+
return
46+
}
47+
4448
span_lint_and_then(
4549
cx,
4650
LET_UNIT_VALUE,

tests/ui/let_unit.fixed

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -175,3 +175,7 @@ fn attributes() {
175175
#[expect(clippy::let_unit_value)]
176176
let _ = f();
177177
}
178+
179+
async fn issue10433() {
180+
let _pending: () = std::future::pending().await;
181+
}

tests/ui/let_unit.rs

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -175,3 +175,7 @@ fn attributes() {
175175
#[expect(clippy::let_unit_value)]
176176
let _ = f();
177177
}
178+
179+
async fn issue10433() {
180+
let _pending: () = std::future::pending().await;
181+
}

0 commit comments

Comments
 (0)