forked from rust-lang/rust
-
Notifications
You must be signed in to change notification settings - Fork 0
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Rollup merge of rust-lang#121119 - compiler-errors:async-fn-kind-errs…
…, r=oli-obk Make `async Fn` trait kind errors better 1. Make it so that async closures with the wrong closurekind actually report a useful error 2. Explain why async closures can sometimes not implement `Fn`/`FnMut` (because they capture things) r? oli-obk
- Loading branch information
Showing
7 changed files
with
154 additions
and
37 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,15 @@ | ||
// edition:2021 | ||
|
||
// FIXME(async_closures): This needs a better error message! | ||
|
||
#![feature(async_closure)] | ||
|
||
fn main() { | ||
fn needs_fn<T>(_: impl FnMut() -> T) {} | ||
|
||
let mut x = 1; | ||
needs_fn(async || { | ||
//~^ ERROR async closure does not implement `FnMut` because it captures state from its environment | ||
x += 1; | ||
}); | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,16 @@ | ||
error: async closure does not implement `FnMut` because it captures state from its environment | ||
--> $DIR/not-fn.rs:11:14 | ||
| | ||
LL | needs_fn(async || { | ||
| -------- ^^^^^^^^ | ||
| | | ||
| required by a bound introduced by this call | ||
| | ||
note: required by a bound in `needs_fn` | ||
--> $DIR/not-fn.rs:8:28 | ||
| | ||
LL | fn needs_fn<T>(_: impl FnMut() -> T) {} | ||
| ^^^^^^^^^^^^ required by this bound in `needs_fn` | ||
|
||
error: aborting due to 1 previous error | ||
|
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters