diff options
| author | Matthias Krüger <matthias.krueger@famsik.de> | 2024-08-15 19:32:36 +0200 |
|---|---|---|
| committer | GitHub <noreply@github.com> | 2024-08-15 19:32:36 +0200 |
| commit | 53bf554de82d64daecf0cf2696cf4da367a96e69 (patch) | |
| tree | 7e9c4c5b2c9dcd61cc43a20d2ebd13644fd710df /compiler/rustc_parse/src | |
| parent | bb63d75ac1477eb361bfee764709f5d54e08cec8 (diff) | |
| parent | 4290943fb35b1e0472d6ee4888c5ab106abe1311 (diff) | |
| download | rust-53bf554de82d64daecf0cf2696cf4da367a96e69.tar.gz rust-53bf554de82d64daecf0cf2696cf4da367a96e69.zip | |
Rollup merge of #129072 - compiler-errors:more-powerful-async-closure-inference, r=lcnr
Infer async closure args from `Fn` bound even if there is no corresponding `Future` bound on return
In #127482, I implemented the functionality to infer an async closure signature when passed into a function that has `Fn` + `Future` where clauses that look like:
```
fn whatever(callback: F)
where
F: Fn(Arg) -> Fut,
Fut: Future<Output = Out>,
```
However, #127781 demonstrates that this is still incomplete to address the cases users care about. So let's not bail when we fail to find a `Future` bound, and try our best to just use the args from the `Fn` bound if we find it. This is *fine* since most users of closures only really care about the *argument* types for inference guidance, since we require the receiver of a `.` method call to be known in order to probe methods.
When I experimented with programmatically rewriting `|| async {}` to `async || {}` in #127827, this also seems to have fixed ~5000 regressions (probably all coming from usages `TryFuture`/`TryStream` from futures-rs): the [before](https://github.com/rust-lang/rust/pull/127827#issuecomment-2254061733) and [after](https://github.com/rust-lang/rust/pull/127827#issuecomment-2255470176) crater runs.
Fixes #127781.
Diffstat (limited to 'compiler/rustc_parse/src')
0 files changed, 0 insertions, 0 deletions
