Skip to content

Commit f54275f

Browse files
committed
Auto merge of rust-lang#11509 - mojave2:issue-11502, r=llogiq
fix FP of let_unit_value on async fn args changelog: [`let_unit_value`]: fix the FalsePostive on async fn arguments fix rust-lang#11502
2 parents 3f9db90 + 7426c83 commit f54275f

File tree

3 files changed

+6
-1
lines changed

3 files changed

+6
-1
lines changed

clippy_lints/src/unit_types/let_unit_value.rs

+2-1
Original file line numberDiff line numberDiff line change
@@ -7,7 +7,7 @@ use rustc_errors::Applicability;
77
use rustc_hir::def::{DefKind, Res};
88
use rustc_hir::{Expr, ExprKind, HirId, HirIdSet, Local, MatchSource, Node, PatKind, QPath, TyKind};
99
use rustc_lint::{LateContext, LintContext};
10-
use rustc_middle::lint::in_external_macro;
10+
use rustc_middle::lint::{in_external_macro, is_from_async_await};
1111
use rustc_middle::ty;
1212

1313
use super::LET_UNIT_VALUE;
@@ -16,6 +16,7 @@ pub(super) fn check<'tcx>(cx: &LateContext<'tcx>, local: &'tcx Local<'_>) {
1616
if let Some(init) = local.init
1717
&& !local.pat.span.from_expansion()
1818
&& !in_external_macro(cx.sess(), local.span)
19+
&& !is_from_async_await(local.span)
1920
&& cx.typeck_results().pat_ty(local.pat).is_unit()
2021
{
2122
if (local.ty.map_or(false, |ty| !matches!(ty.kind, TyKind::Infer))

tests/ui/let_unit.fixed

+2
Original file line numberDiff line numberDiff line change
@@ -177,3 +177,5 @@ fn attributes() {
177177
async fn issue10433() {
178178
let _pending: () = std::future::pending().await;
179179
}
180+
181+
pub async fn issue11502(a: ()) {}

tests/ui/let_unit.rs

+2
Original file line numberDiff line numberDiff line change
@@ -177,3 +177,5 @@ fn attributes() {
177177
async fn issue10433() {
178178
let _pending: () = std::future::pending().await;
179179
}
180+
181+
pub async fn issue11502(a: ()) {}

0 commit comments

Comments
 (0)