about summary refs log tree commit diff
diff options
context:
space:
mode:
authorbors <bors@rust-lang.org>2023-09-16 10:22:33 +0000
committerbors <bors@rust-lang.org>2023-09-16 10:22:33 +0000
commitf54275f20fb4aa20e28e6f082fac8cfc044965a4 (patch)
tree47764568ee2ce65068efa2d7850f879e2234d420
parent3f9db9025d9a210e1e3c0dbac54f52cb25fd6784 (diff)
parent7426c83d8f5d1688763642503b59d0f0f653a3f5 (diff)
downloadrust-f54275f20fb4aa20e28e6f082fac8cfc044965a4.tar.gz
rust-f54275f20fb4aa20e28e6f082fac8cfc044965a4.zip
Auto merge of #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 #11502
-rw-r--r--clippy_lints/src/unit_types/let_unit_value.rs3
-rw-r--r--tests/ui/let_unit.fixed2
-rw-r--r--tests/ui/let_unit.rs2
3 files changed, 6 insertions, 1 deletions
diff --git a/clippy_lints/src/unit_types/let_unit_value.rs b/clippy_lints/src/unit_types/let_unit_value.rs
index 704d7abd7e5..e7915953d85 100644
--- a/clippy_lints/src/unit_types/let_unit_value.rs
+++ b/clippy_lints/src/unit_types/let_unit_value.rs
@@ -7,7 +7,7 @@ use rustc_errors::Applicability;
 use rustc_hir::def::{DefKind, Res};
 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::lint::{in_external_macro, is_from_async_await};
 use rustc_middle::ty;
 
 use super::LET_UNIT_VALUE;
@@ -16,6 +16,7 @@ pub(super) fn check<'tcx>(cx: &LateContext<'tcx>, local: &'tcx Local<'_>) {
     if let Some(init) = local.init
         && !local.pat.span.from_expansion()
         && !in_external_macro(cx.sess(), local.span)
+        && !is_from_async_await(local.span)
         && cx.typeck_results().pat_ty(local.pat).is_unit()
     {
         if (local.ty.map_or(false, |ty| !matches!(ty.kind, TyKind::Infer))
diff --git a/tests/ui/let_unit.fixed b/tests/ui/let_unit.fixed
index 57374bd5fcd..f98ce9d50a9 100644
--- a/tests/ui/let_unit.fixed
+++ b/tests/ui/let_unit.fixed
@@ -177,3 +177,5 @@ fn attributes() {
 async fn issue10433() {
     let _pending: () = std::future::pending().await;
 }
+
+pub async fn issue11502(a: ()) {}
diff --git a/tests/ui/let_unit.rs b/tests/ui/let_unit.rs
index 09077c60d50..6d942ca8908 100644
--- a/tests/ui/let_unit.rs
+++ b/tests/ui/let_unit.rs
@@ -177,3 +177,5 @@ fn attributes() {
 async fn issue10433() {
     let _pending: () = std::future::pending().await;
 }
+
+pub async fn issue11502(a: ()) {}