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
This commit is contained in:
Matthias Krüger
2025-05-22 16:04:12 +02:00
committed by GitHub
3 changed files with 21 additions and 8 deletions

View File

@@ -327,7 +327,7 @@ pub(in crate::solve) fn extract_tupled_inputs_and_output_from_callable<I: Intern
// always be called once. It additionally implements `Fn`/`FnMut`
// only if it has no upvars referencing the closure-env lifetime,
// and if the closure kind permits it.
if closure_kind != ty::ClosureKind::FnOnce && args.has_self_borrows() {
if goal_kind != ty::ClosureKind::FnOnce && args.has_self_borrows() {
return Err(NoSolution);
}