about summary refs log tree commit diff
path: root/tests
diff options
context:
space:
mode:
authorllogiq <bogusandre@gmail.com>2025-05-31 08:47:19 +0000
committerGitHub <noreply@github.com>2025-05-31 08:47:19 +0000
commit2948678647a298047a42c72d7060bf509d74bd1d (patch)
treef2273702a12ba2d4e4e0f9491fedbcdf0bdc2576 /tests
parent010c2d3793db229ee139e26f08fc6600149a7afe (diff)
parent76316488e8667901d9926a4f4c3b2de30866d7bb (diff)
downloadrust-2948678647a298047a42c72d7060bf509d74bd1d.tar.gz
rust-2948678647a298047a42c72d7060bf509d74bd1d.zip
Fix `dbg_macro` fail to handle async coroutine desugar (#14937)
Closes rust-lang/rust-clippy#14914

----

changelog: [`dbg_macro`]: fix mishandling of async coroutine desugar
Diffstat (limited to 'tests')
-rw-r--r--tests/ui/dbg_macro/dbg_macro.fixed16
-rw-r--r--tests/ui/dbg_macro/dbg_macro.rs16
-rw-r--r--tests/ui/dbg_macro/dbg_macro.stderr14
3 files changed, 45 insertions, 1 deletions
diff --git a/tests/ui/dbg_macro/dbg_macro.fixed b/tests/ui/dbg_macro/dbg_macro.fixed
index 3b9dee81898..5993c2faf0d 100644
--- a/tests/ui/dbg_macro/dbg_macro.fixed
+++ b/tests/ui/dbg_macro/dbg_macro.fixed
@@ -123,3 +123,19 @@ mod issue12131 {
         //~^ dbg_macro
     }
 }
+
+mod issue14914 {
+    use std::future::Future;
+
+    fn takes_async_fn<F, Fut>(_f: F)
+    where
+        F: FnOnce(i32) -> Fut,
+        Fut: Future<Output = i32>,
+    {
+    }
+
+    fn should_not_panic() {
+        takes_async_fn(async |val| val);
+        //~^ dbg_macro
+    }
+}
diff --git a/tests/ui/dbg_macro/dbg_macro.rs b/tests/ui/dbg_macro/dbg_macro.rs
index 1dbbc6fe984..58d7e106e23 100644
--- a/tests/ui/dbg_macro/dbg_macro.rs
+++ b/tests/ui/dbg_macro/dbg_macro.rs
@@ -123,3 +123,19 @@ mod issue12131 {
         //~^ dbg_macro
     }
 }
+
+mod issue14914 {
+    use std::future::Future;
+
+    fn takes_async_fn<F, Fut>(_f: F)
+    where
+        F: FnOnce(i32) -> Fut,
+        Fut: Future<Output = i32>,
+    {
+    }
+
+    fn should_not_panic() {
+        takes_async_fn(async |val| dbg!(val));
+        //~^ dbg_macro
+    }
+}
diff --git a/tests/ui/dbg_macro/dbg_macro.stderr b/tests/ui/dbg_macro/dbg_macro.stderr
index f1412023cc8..5a65b38a85c 100644
--- a/tests/ui/dbg_macro/dbg_macro.stderr
+++ b/tests/ui/dbg_macro/dbg_macro.stderr
@@ -230,5 +230,17 @@ LL -         print!("{}", dbg!(s));
 LL +         print!("{}", s);
    |
 
-error: aborting due to 19 previous errors
+error: the `dbg!` macro is intended as a debugging tool
+  --> tests/ui/dbg_macro/dbg_macro.rs:138:36
+   |
+LL |         takes_async_fn(async |val| dbg!(val));
+   |                                    ^^^^^^^^^
+   |
+help: remove the invocation before committing it to a version control system
+   |
+LL -         takes_async_fn(async |val| dbg!(val));
+LL +         takes_async_fn(async |val| val);
+   |
+
+error: aborting due to 20 previous errors