diff options
| author | mojave2 <chenchen145@huawei.com> | 2023-09-15 15:05:43 +0800 |
|---|---|---|
| committer | mojave2 <chenchen145@huawei.com> | 2023-09-15 15:05:43 +0800 |
| commit | c81888eab32e09318a9b95fdad22aea27f6933ea (patch) | |
| tree | 5d7d8485bda4e7eefcfffc498563ed439979af4d | |
| parent | 0273ed3afd1cb032655aef0019c448b9a6950731 (diff) | |
| download | rust-c81888eab32e09318a9b95fdad22aea27f6933ea.tar.gz rust-c81888eab32e09318a9b95fdad22aea27f6933ea.zip | |
fix FP of let_unit_value on async fn args
| -rw-r--r-- | clippy_lints/src/unit_types/let_unit_value.rs | 3 |
1 files changed, 2 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)) |
