diff options
| author | Matthias Krüger <matthias.krueger@famsik.de> | 2024-06-25 18:03:01 +0200 |
|---|---|---|
| committer | GitHub <noreply@github.com> | 2024-06-25 18:03:01 +0200 |
| commit | dad39e884093ee22e1dae1395d92a29b6b91b657 (patch) | |
| tree | 75a8a56adc58c59dda98f75ca32c8e7a02affc7b /compiler/rustc_pattern_analysis/tests/complexity.rs | |
| parent | 709baaef133117b19faa785dc51aaa0f3c1560f0 (diff) | |
| parent | 26677eb06efbd976e2a3b1c30eacf8e22c8c831c (diff) | |
| download | rust-dad39e884093ee22e1dae1395d92a29b6b91b657.tar.gz rust-dad39e884093ee22e1dae1395d92a29b6b91b657.zip | |
Rollup merge of #126915 - SparkyPotato:fix-126903, r=compiler-errors
Don't suggest awaiting in closure patterns
Fixes #126903.
For
```rust
async fn do_async() {}
fn main() {
Some(do_async()).map(|()| {});
}
```
the error is now
```rust
error[E0308]: mismatched types
--> src/main.rs:4:27
|
4 | Some(do_async()).map(|()| {});
| ^^
| |
| expected future, found `()`
| expected due to this
|
= note: expected opaque type `impl Future<Output = ()>`
found unit type `()`
```
Ideally, if `main` were to be `async`, it should be
```rs
error[E0308]: mismatched types
--> src/main.rs:4:27
|
4 | Some(do_async()).map(|()| {});
| ^^
| |
| expected future, found `()`
| expected due to this
|
= note: expected opaque type `impl Future<Output = ()>`
found unit type `()`
help: consider `await`ing on the `Future`
|
4 | Some(do_async().await).map(|()| {});
| ++++++
```
However, this would mean `FnCtx::check_pat_top` would have to be called with an `origin_expr` in `rustc_hir_typeck::check::check_fn`, and that expr would have to be somehow plumbed through `FnCtxt::check_expr_closure` and closure signature deduction. I'm willing to work on the plumbing but unsure how to start.
Diffstat (limited to 'compiler/rustc_pattern_analysis/tests/complexity.rs')
0 files changed, 0 insertions, 0 deletions
