diff options
| author | Guillaume Gomez <guillaume1.gomez@gmail.com> | 2024-07-08 20:23:41 +0200 |
|---|---|---|
| committer | GitHub <noreply@github.com> | 2024-07-08 20:23:41 +0200 |
| commit | 72199b2c52916edca9f585877608a156b313d66b (patch) | |
| tree | 712e6ad671478d669cfceac2d4e46368a0777907 /compiler/rustc_codegen_gcc | |
| parent | 081cca13bdac1b00a124bdcedfa1b67e4ee891c2 (diff) | |
| parent | f4f678f27e84254cc89fd53ae20e467a254982de (diff) | |
| download | rust-72199b2c52916edca9f585877608a156b313d66b.tar.gz rust-72199b2c52916edca9f585877608a156b313d66b.zip | |
Rollup merge of #127482 - compiler-errors:closure-two-par-sig-inference, r=oli-obk
Infer async closure signature from (old-style) two-part `Fn` + `Future` bounds
When an async closure is passed to a function that has a "two-part" `Fn` and `Future` trait bound, like:
```rust
use std::future::Future;
fn not_exactly_an_async_closure(_f: F)
where
F: FnOnce(String) -> Fut,
Fut: Future<Output = ()>,
{}
```
The we want to be able to extract the signature to guide inference in the async closure, like:
```rust
not_exactly_an_async_closure(async |string| {
for x in string.split('\n') { ... }
//~^ We need to know that the type of `string` is `String` to call methods on it.
})
```
Closure signature inference will see two bounds: `<?F as FnOnce<Args>>::Output = ?Fut`, `<?Fut as Future>::Output = String`. We need to extract the signature by looking through both projections.
### Why?
I expect the ecosystem's move onto `async Fn` trait bounds (which are not affected by this PR, and already do signature inference fine) to be slow. In the mean time, I don't see major overhead to supporting this "old–style" of trait bounds that were used to model async closures.
r? oli-obk
Fixes #127468
Fixes #127425
Diffstat (limited to 'compiler/rustc_codegen_gcc')
0 files changed, 0 insertions, 0 deletions
