Skip to content

Commit

Permalink
Auto merge of #11509 - mojave2:issue-11502, r=llogiq
Browse files Browse the repository at this point in the history
fix FP of let_unit_value on async fn args

changelog: [`let_unit_value`]: fix the FalsePostive on async fn arguments

fix #11502
  • Loading branch information
bors committed Sep 16, 2023
2 parents 3f9db90 + 7426c83 commit f54275f
Show file tree
Hide file tree
Showing 3 changed files with 6 additions and 1 deletion.
3 changes: 2 additions & 1 deletion clippy_lints/src/unit_types/let_unit_value.rs
Original file line number Diff line number Diff line change
Expand Up @@ -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;
Expand All @@ -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))
Expand Down
2 changes: 2 additions & 0 deletions tests/ui/let_unit.fixed
Original file line number Diff line number Diff line change
Expand Up @@ -177,3 +177,5 @@ fn attributes() {
async fn issue10433() {
let _pending: () = std::future::pending().await;
}

pub async fn issue11502(a: ()) {}
2 changes: 2 additions & 0 deletions tests/ui/let_unit.rs
Original file line number Diff line number Diff line change
Expand Up @@ -177,3 +177,5 @@ fn attributes() {
async fn issue10433() {
let _pending: () = std::future::pending().await;
}

pub async fn issue11502(a: ()) {}

0 comments on commit f54275f

Please sign in to comment.