about summary refs log tree commit diff
diff options
context:
space:
mode:
authorxFrednet <xFrednet@gmail.com>2022-06-06 14:03:11 +0200
committerxFrednet <xFrednet@gmail.com>2022-06-06 14:13:28 +0200
commit8db734990be40e2acd59c2b20bf6e02343830fd6 (patch)
tree369061d73a13e789ea4f23cd47583bd5a4ed10bf
parent7e1730e16c779f688392e0edcd553036b2afe1f1 (diff)
downloadrust-8db734990be40e2acd59c2b20bf6e02343830fd6.tar.gz
rust-8db734990be40e2acd59c2b20bf6e02343830fd6.zip
Fix `#[expect]` for `async_yields_async`
-rw-r--r--clippy_lints/src/async_yields_async.rs5
-rw-r--r--clippy_lints/src/same_name_method.rs1
-rw-r--r--tests/ui/async_yields_async.fixed13
-rw-r--r--tests/ui/async_yields_async.rs13
-rw-r--r--tests/ui/needless_borrow.fixed1
-rw-r--r--tests/ui/needless_borrow.rs1
6 files changed, 30 insertions, 4 deletions
diff --git a/clippy_lints/src/async_yields_async.rs b/clippy_lints/src/async_yields_async.rs
index 0619490e73c..d32724d040c 100644
--- a/clippy_lints/src/async_yields_async.rs
+++ b/clippy_lints/src/async_yields_async.rs
@@ -1,4 +1,4 @@
-use clippy_utils::diagnostics::span_lint_and_then;
+use clippy_utils::diagnostics::span_lint_hir_and_then;
 use clippy_utils::source::snippet;
 use clippy_utils::ty::implements_trait;
 use rustc_errors::Applicability;
@@ -63,9 +63,10 @@ impl<'tcx> LateLintPass<'tcx> for AsyncYieldsAsync {
                         _ => None,
                     };
                     if let Some(return_expr_span) = return_expr_span {
-                        span_lint_and_then(
+                        span_lint_hir_and_then(
                             cx,
                             ASYNC_YIELDS_ASYNC,
+                            body.value.hir_id,
                             return_expr_span,
                             "an async construct yields a type which is itself awaitable",
                             |db| {
diff --git a/clippy_lints/src/same_name_method.rs b/clippy_lints/src/same_name_method.rs
index 04d9ee7d912..73f8e083b29 100644
--- a/clippy_lints/src/same_name_method.rs
+++ b/clippy_lints/src/same_name_method.rs
@@ -47,6 +47,7 @@ struct ExistingName {
 }
 
 impl<'tcx> LateLintPass<'tcx> for SameNameMethod {
+    #[expect(clippy::too_many_lines)]
     fn check_crate_post(&mut self, cx: &LateContext<'tcx>) {
         let mut map = FxHashMap::<Res, ExistingName>::default();
 
diff --git a/tests/ui/async_yields_async.fixed b/tests/ui/async_yields_async.fixed
index e20b58269b9..3cf380d2b95 100644
--- a/tests/ui/async_yields_async.fixed
+++ b/tests/ui/async_yields_async.fixed
@@ -1,5 +1,5 @@
 // run-rustfix
-
+#![feature(lint_reasons)]
 #![feature(async_closure)]
 #![warn(clippy::async_yields_async)]
 
@@ -65,3 +65,14 @@ fn main() {
     let _n = async || custom_future_type_ctor();
     let _o = async || f();
 }
+
+#[rustfmt::skip]
+#[allow(dead_code)]
+fn check_expect_suppression() {
+    #[expect(clippy::async_yields_async)]
+    let _j = async || {
+        async {
+            3
+        }
+    };
+}
diff --git a/tests/ui/async_yields_async.rs b/tests/ui/async_yields_async.rs
index c1dfa398450..dd4131b60ab 100644
--- a/tests/ui/async_yields_async.rs
+++ b/tests/ui/async_yields_async.rs
@@ -1,5 +1,5 @@
 // run-rustfix
-
+#![feature(lint_reasons)]
 #![feature(async_closure)]
 #![warn(clippy::async_yields_async)]
 
@@ -65,3 +65,14 @@ fn main() {
     let _n = async || custom_future_type_ctor();
     let _o = async || f();
 }
+
+#[rustfmt::skip]
+#[allow(dead_code)]
+fn check_expect_suppression() {
+    #[expect(clippy::async_yields_async)]
+    let _j = async || {
+        async {
+            3
+        }
+    };
+}
diff --git a/tests/ui/needless_borrow.fixed b/tests/ui/needless_borrow.fixed
index 6b1576d6732..e7a483c0582 100644
--- a/tests/ui/needless_borrow.fixed
+++ b/tests/ui/needless_borrow.fixed
@@ -99,6 +99,7 @@ impl<'a> Trait for &'a str {}
 
 fn h(_: &dyn Trait) {}
 
+#[allow(dead_code)]
 fn check_expect_suppression() {
     let a = 5;
     #[expect(clippy::needless_borrow)]
diff --git a/tests/ui/needless_borrow.rs b/tests/ui/needless_borrow.rs
index ebe76361db4..1d6bf46405a 100644
--- a/tests/ui/needless_borrow.rs
+++ b/tests/ui/needless_borrow.rs
@@ -99,6 +99,7 @@ impl<'a> Trait for &'a str {}
 
 fn h(_: &dyn Trait) {}
 
+#[allow(dead_code)]
 fn check_expect_suppression() {
     let a = 5;
     #[expect(clippy::needless_borrow)]