about summary refs log tree commit diff
diff options
context:
space:
mode:
authorbors <bors@rust-lang.org>2024-03-03 13:20:11 +0000
committerbors <bors@rust-lang.org>2024-03-03 13:20:11 +0000
commit28e11b31deef5fd0f59a1e289f8f2173ed6e5944 (patch)
tree095a2dab01a425a310c8780085cbd3d8b93167c7
parent5e0afee334366daeaa576e20e926a1a39f332fca (diff)
parent1df2854ac3215dcaf8c1e6b366b61cb51fbf7cbd (diff)
downloadrust-28e11b31deef5fd0f59a1e289f8f2173ed6e5944.tar.gz
rust-28e11b31deef5fd0f59a1e289f8f2173ed6e5944.zip
Auto merge of #12400 - samueltardieu:issue-12395, r=Alexendoo
[`let_underscore_untyped`]: fix false positive on async function

changelog: [`let_underscore_untyped`]: fix false positive on async function

Fix #12395
-rw-r--r--clippy_lints/src/let_underscore.rs5
-rw-r--r--tests/ui/let_underscore_untyped.rs2
2 files changed, 5 insertions, 2 deletions
diff --git a/clippy_lints/src/let_underscore.rs b/clippy_lints/src/let_underscore.rs
index 606c2ed72be..0ea53c39280 100644
--- a/clippy_lints/src/let_underscore.rs
+++ b/clippy_lints/src/let_underscore.rs
@@ -1,7 +1,7 @@
 use clippy_utils::diagnostics::span_lint_and_help;
 use clippy_utils::ty::{implements_trait, is_must_use_ty, match_type};
 use clippy_utils::{is_from_proc_macro, is_must_use_func_call, paths};
-use rustc_hir::{Local, PatKind};
+use rustc_hir::{Local, LocalSource, PatKind};
 use rustc_lint::{LateContext, LateLintPass};
 use rustc_middle::lint::in_external_macro;
 use rustc_middle::ty::{GenericArgKind, IsSuggestable};
@@ -139,7 +139,8 @@ const SYNC_GUARD_PATHS: [&[&str]; 3] = [
 
 impl<'tcx> LateLintPass<'tcx> for LetUnderscore {
     fn check_local(&mut self, cx: &LateContext<'tcx>, local: &Local<'tcx>) {
-        if !in_external_macro(cx.tcx.sess, local.span)
+        if matches!(local.source, LocalSource::Normal)
+            && !in_external_macro(cx.tcx.sess, local.span)
             && let PatKind::Wild = local.pat.kind
             && let Some(init) = local.init
         {
diff --git a/tests/ui/let_underscore_untyped.rs b/tests/ui/let_underscore_untyped.rs
index bd94a3ada18..6275b6f970a 100644
--- a/tests/ui/let_underscore_untyped.rs
+++ b/tests/ui/let_underscore_untyped.rs
@@ -73,3 +73,5 @@ fn main() {
     #[allow(clippy::let_underscore_untyped)]
     let _ = a();
 }
+
+async fn dont_lint_async_prototype(_: u8) {}