about summary refs log tree commit diff
path: root/tests
diff options
context:
space:
mode:
authorMatthias Krüger <476013+matthiaskrgr@users.noreply.github.com>2025-05-22 16:04:12 +0200
committerGitHub <noreply@github.com>2025-05-22 16:04:12 +0200
commit654b2f39f19fac2aaa9a46a89a94048128067300 (patch)
treec2b15aec5811a9f7a47c89dabe299f656efc6914 /tests
parent8757915a70e3e8598ef8b91ff61a2aab37f25147 (diff)
parente0f80558716372902b2eda1e43ab2e169bfb3669 (diff)
downloadrust-654b2f39f19fac2aaa9a46a89a94048128067300.tar.gz
rust-654b2f39f19fac2aaa9a46a89a94048128067300.zip
Rollup merge of #141359 - compiler-errors:async-fn-once, r=lcnr
Fix `FnOnce` impl for `AsyncFn`/`AsyncFnMut` self-borrowing closures in new solver

This only affects closures that are "`AsyncFn`/`AsyncFnMut`" in their calling capability that are being called with the `FnOnce` trait.

fixes https://github.com/rust-lang/trait-system-refactor-initiative/issues/217

r? lcnr
Diffstat (limited to 'tests')
-rw-r--r--tests/ui/async-await/async-closures/async-fn-mut-impl-fn-once.rs15
1 files changed, 15 insertions, 0 deletions
diff --git a/tests/ui/async-await/async-closures/async-fn-mut-impl-fn-once.rs b/tests/ui/async-await/async-closures/async-fn-mut-impl-fn-once.rs
new file mode 100644
index 00000000000..59d034953d7
--- /dev/null
+++ b/tests/ui/async-await/async-closures/async-fn-mut-impl-fn-once.rs
@@ -0,0 +1,15 @@
+//@ edition:2021
+//@ check-pass
+//@ revisions: current next
+//@ ignore-compare-mode-next-solver (explicit revisions)
+//@[next] compile-flags: -Znext-solver
+
+fn call_once<F>(_: impl FnOnce() -> F) {}
+
+fn main() {
+    let mut i = 0;
+    let c = async || {
+        i += 1;
+    };
+    call_once(c);
+}