-
Notifications
You must be signed in to change notification settings - Fork 12.7k
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Adds a clearer message for when the async keyword is missing from a f… #73672
Conversation
Thanks for the pull request, and welcome! The Rust team is excited to review your changes, and you should hear from @kennytm (or someone else) soon. If any changes to this PR are deemed necessary, please add them as extra commits. This ensures that the reviewer can see what has changed since they last reviewed the code. Due to the way GitHub handles out-of-date commits, this should also make it reasonably obvious what issues have or haven't been addressed. Large or tricky changes may require several passes of review and changes. Please see the contribution instructions for more information. |
The job Click to expand the log.
I'm a bot! I can only do what humans tell me to, so if this was not helpful or you have suggestions for improvements, please ping or otherwise contact |
r? @estebank |
@nellshamrell Can you run |
The job Click to expand the log.
I'm a bot! I can only do what humans tell me to, so if this was not helpful or you have suggestions for improvements, please ping or otherwise contact |
It seems like you need to call |
The job Click to expand the log.
I'm a bot! I can only do what humans tell me to, so if this was not helpful or you have suggestions for improvements, please ping or otherwise contact |
…unction Signed-off-by: Nell Shamrell <[email protected]>
@estebank I think this is good to go now! |
@bors r+ |
📌 Commit 5e28eb5 has been approved by |
Adds a clearer message for when the async keyword is missing from a f… …unction This is a somewhat simple fix for rust-lang#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](rust-lang#66731 (comment)). 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 <[email protected]>
Adds a clearer message for when the async keyword is missing from a f… …unction This is a somewhat simple fix for rust-lang#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](rust-lang#66731 (comment)). 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 <[email protected]>
Adds a clearer message for when the async keyword is missing from a f… …unction This is a somewhat simple fix for rust-lang#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](rust-lang#66731 (comment)). 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 <[email protected]>
…arth Rollup of 10 pull requests Successful merges: - rust-lang#72796 (MIR sanity check: validate types on assignment) - rust-lang#73243 (Add documentation to point to `File::open` or `OpenOptions::open` instead of `is_file` to check read/write possibility) - rust-lang#73525 (Prepare for LLVM 11) - rust-lang#73672 (Adds a clearer message for when the async keyword is missing from a f…) - rust-lang#73708 (Explain move errors that occur due to method calls involving `self` (take two)) - rust-lang#73758 (improper_ctypes: fix remaining `Reveal:All`) - rust-lang#73763 (errors: use `-Z terminal-width` in JSON emitter) - rust-lang#73796 (replace more `DefId`s with `LocalDefId`) - rust-lang#73797 (fix typo in self-profile.md) - rust-lang#73809 (Add links to fs::DirEntry::metadata) Failed merges: r? @ghost
…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:
And they attempt to run it, they will receive an error message that looks like this:
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:
In the future, I think we should make this error message even clearer, perhaps through a solution like the one described in this comment. 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 [email protected]