Skip to content

Commit 81153b5

Browse files
Fix FnOnce impl for AsyncFnOnce closures in new solver
1 parent 6cf4f48 commit 81153b5

File tree

2 files changed

+16
-1
lines changed

2 files changed

+16
-1
lines changed

compiler/rustc_next_trait_solver/src/solve/assembly/structural_traits.rs

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -327,7 +327,7 @@ pub(in crate::solve) fn extract_tupled_inputs_and_output_from_callable<I: Intern
327327
// always be called once. It additionally implements `Fn`/`FnMut`
328328
// only if it has no upvars referencing the closure-env lifetime,
329329
// and if the closure kind permits it.
330-
if closure_kind != ty::ClosureKind::FnOnce && args.has_self_borrows() {
330+
if goal_kind != ty::ClosureKind::FnOnce && args.has_self_borrows() {
331331
return Err(NoSolution);
332332
}
333333

Lines changed: 15 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,15 @@
1+
//@ edition:2021
2+
//@ check-pass
3+
//@ revisions: current next
4+
//@ ignore-compare-mode-next-solver (explicit revisions)
5+
//@[next] compile-flags: -Znext-solver
6+
7+
fn call_once<F>(_: impl FnOnce() -> F) {}
8+
9+
fn main() {
10+
let mut i = 0;
11+
let c = async || {
12+
i += 1;
13+
};
14+
call_once(c);
15+
}

0 commit comments

Comments
 (0)