diff options
| author | Manish Goregaokar <manishsmail@gmail.com> | 2020-06-27 22:29:55 -0700 |
|---|---|---|
| committer | GitHub <noreply@github.com> | 2020-06-27 22:29:55 -0700 |
| commit | d227a825bc6122c9e38d33cba5789a209934576f (patch) | |
| tree | 10521cbdef4c77eac5d749ff5372a5250dbc5392 /library/std/src/sys/unix/stack_overflow.rs | |
| parent | 45ec25e088efeabd21c793bde8ab7a05103cc8d2 (diff) | |
| parent | 5e28eb580ff48a84fe6f49bff31c4c022f243ac9 (diff) | |
| download | rust-d227a825bc6122c9e38d33cba5789a209934576f.tar.gz rust-d227a825bc6122c9e38d33cba5789a209934576f.zip | |
Rollup merge of #73672 - nellshamrell:async-fix, r=estebank
Adds a clearer message for when the async keyword is missing from a f…
…unction
This is a somewhat simple fix for #66731.
Under the current version of Rust, if a user has a rust file that looks like this:
```rust
fn boo (){}
async fn foo() {
boo().await;
}
fn main() {
}
```
And they attempt to run it, they will receive an error message that looks like this:
```bash
error: incorrect use of `await` --> test.rs:4:14 | 4 | boo.await(); | ^^ help: `await` is not a method call, remove the parentheses error[E0277]: the trait bound `fn() {boo}: std::future::Future` is not satisfied --> test.rs:4:5 | 4 | boo.await(); | ^^^^^^^^^ the trait `std::future::Future` is not implemented for `fn() {boo}` error: aborting due to 2 previous errors For more information about this error, try `rustc --explain E0277`.
```
This is not very clear.
With the changes made in this PR, when a user compiles and runs that same rust code, they will receive an error message that looks like this:
```bash
error[E0277]: `()` is not a future.
--> test.rs:4:5
|
4 | boo().await;
| ^^^^^^^^^^^ `()` is not a future
|
= help: the trait `std::future::Future` is not implemented for `()`
= note: required by `std::future::Future::poll`
```
In the future, I think we should make this error message even clearer, perhaps through a solution like the one described in [this comment](https://github.com/rust-lang/rust/issues/66731#issuecomment-644394287). However, as that potentially involves a major change proposal, I would rather get this change in now and make the error message a little clearer while an MCP is drafted and discussed.
Signed-off-by: Nell Shamrell <nellshamrell@gmail.com>
Diffstat (limited to 'library/std/src/sys/unix/stack_overflow.rs')
0 files changed, 0 insertions, 0 deletions
