Skip to content

Commit 8c79546

Browse files
committed
Auto merge of #123497 - GuillaumeGomez:rollup-usqb4q9, r=GuillaumeGomez
Rollup of 8 pull requests Successful merges: - #122334 (Vendor rustc_codegen_gcc) - #122894 (Move check for error in impl header outside of reporting) - #123149 (Port argument-non-c-like-enum to Rust) - #123311 (Match ergonomics: implement "`&`pat everywhere") - #123350 (Actually use the inferred `ClosureKind` from signature inference in coroutine-closures) - #123474 (Port `run-make/issue-7349` to a codegen test) - #123489 (handle rustc args properly in bootstrap) - #123496 (ping on wf changes, remove fixme) r? `@ghost` `@rustbot` modify labels: rollup
2 parents 6f65d83 + bc17ba9 commit 8c79546

File tree

2 files changed

+38
-0
lines changed

2 files changed

+38
-0
lines changed

tests/pass/async-closure-captures.rs

Lines changed: 34 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -88,4 +88,38 @@ async fn async_main() {
8888
};
8989
call_once(c).await;
9090
}
91+
92+
fn force_fnonce<T>(f: impl async FnOnce() -> T) -> impl async FnOnce() -> T {
93+
f
94+
}
95+
96+
// Capture something with `move`, but infer to `AsyncFnOnce`
97+
{
98+
let x = Hello(6);
99+
let c = force_fnonce(async move || {
100+
println!("{x:?}");
101+
});
102+
call_once(c).await;
103+
104+
let x = &Hello(7);
105+
let c = force_fnonce(async move || {
106+
println!("{x:?}");
107+
});
108+
call_once(c).await;
109+
}
110+
111+
// Capture something by-ref, but infer to `AsyncFnOnce`
112+
{
113+
let x = Hello(8);
114+
let c = force_fnonce(async || {
115+
println!("{x:?}");
116+
});
117+
call_once(c).await;
118+
119+
let x = &Hello(9);
120+
let c = force_fnonce(async || {
121+
println!("{x:?}");
122+
});
123+
call_once(c).await;
124+
}
91125
}

tests/pass/async-closure-captures.stdout

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -8,3 +8,7 @@ Hello(3)
88
Hello(4)
99
Hello(4)
1010
Hello(5)
11+
Hello(6)
12+
Hello(7)
13+
Hello(8)
14+
Hello(9)

0 commit comments

Comments
 (0)