about summary refs log tree commit diff
diff options
context:
space:
mode:
authorlcnr <rust@lcnr.de>2025-09-24 15:02:41 +0200
committerlcnr <rust@lcnr.de>2025-09-24 15:02:41 +0200
commit7a0adc08786df857e810c9f6a5a0cb6cae32659b (patch)
treedc83a8acde0508f9384628f4225c0a9371a28e0e
parent83532f8544e18dfc2025ab33e7c01fb27865667f (diff)
downloadrust-7a0adc08786df857e810c9f6a5a0cb6cae32659b.tar.gz
rust-7a0adc08786df857e810c9f6a5a0cb6cae32659b.zip
add test
-rw-r--r--tests/ui/coroutine/copy-fast-path-query-cycle.rs40
1 files changed, 40 insertions, 0 deletions
diff --git a/tests/ui/coroutine/copy-fast-path-query-cycle.rs b/tests/ui/coroutine/copy-fast-path-query-cycle.rs
new file mode 100644
index 00000000000..644cba0d47a
--- /dev/null
+++ b/tests/ui/coroutine/copy-fast-path-query-cycle.rs
@@ -0,0 +1,40 @@
+//@ edition: 2024
+//@ revisions: current next
+//@[next] compile-flags: -Znext-solver
+//@ check-pass
+
+// Regression test for #146813. We previously used a pseudo-canonical
+// query during HIR typeck which caused a query cycle when looking at the
+// witness of a coroutine.
+
+use std::future::Future;
+
+trait ConnectMiddleware {}
+
+trait ConnectHandler: Sized {
+    fn with<M>(self, _: M) -> impl ConnectHandler
+    where
+        M: ConnectMiddleware,
+    {
+        LayeredConnectHandler
+    }
+}
+
+struct LayeredConnectHandler;
+impl ConnectHandler for LayeredConnectHandler {}
+impl<F> ConnectHandler for F where F: FnOnce() {}
+
+impl<F, Fut> ConnectMiddleware for F
+where
+    F: FnOnce() -> Fut,
+    Fut: Future<Output = ()> + Send,
+{
+}
+
+pub async fn fails() {
+    { || {} }
+        .with(async || ())
+        .with(async || ())
+        .with(async || ());
+}
+fn main() {}