Fix FnOnce impl for AsyncFn/AsyncFnMut closures in new solver

This commit is contained in:
Michael Goulet 2025-05-21 18:07:29 +00:00
parent ca912d794d
commit e0f8055871
2 changed files with 16 additions and 1 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);
}

View File

@ -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);
}