Uh oh!
There was an error while loading. Please reload this page.
Reword labels on E0308 involving async fn return type - #82165
Conversation
rust-highfive
commented
Feb 16, 2021
r? @estebank (rust-highfive has picked a reviewer for you, use r? to override) |
guswynn
commented
Feb 16, 2021
I think I noticed this weird wording on #81496 and I think this will fix it! Nice! |
There was a problem hiding this comment.
I'm not sure how cumbersome it might be to procure, but if we had the Span for make_u32 we could have the following output:
error[E0308]: mismatched types
--> $DIR/dont-suggest-missing-await.rs:14:18
|
LL | async fn make_u32() -> u32 {
| -------- --- checked the `Output` of this `async fn`, found opaque type
| |
| while checking the return type of this `async fn`
...
LL | take_u32(x)
| ^ expected `u32`, found opaque type
|
= note: expected type `u32`
found opaque type `impl Future`
help: consider `await`ing on the `Future`
|
LL | take_u32(x.await)
| ^^^^^^
If getting it is too difficult, then we should reword the note to be "while checking the return type of the async fn", because the note has no span and the output on both the CLI and third-party tools might be ambiguous.
estebank
commented
Feb 16, 2021
After doing either of the options, could you squash your commits? With those nitpicks addressed, this can be landed :) |
This comment has been minimized.
This comment has been minimized.
There was a problem hiding this comment.
I think you'll have to keep a local that checks if you have noted this in this loop already
In the rebase on my pr, this message shows up twice in 1 diagnostic
There was a problem hiding this comment.
I will experiment with this (likely tomorrow), but is there any chance you could point me to a place in the code base where it does a similar local check in the loop?
There was a problem hiding this comment.
Experimented and I think I've got what you suggested working. Would you mind trying it out when you have a moment?
This comment has been minimized.
This comment has been minimized.
This comment has been minimized.
This comment has been minimized.
Uh oh!
There was an error while loading. Please reload this page.
Uh oh!
There was an error while loading. Please reload this page.
This comment has been minimized.
This comment has been minimized.
estebank
commented
Feb 22, 2021
It seems like you'll have to |
…tions Signed-off-by: Nell Shamrell <nellshamrell@gmail.com>
nellshamrell
commented
Feb 25, 2021
@estebank I think this is ready to go now! |
estebank
commented
Feb 25, 2021
@bors r+ |
bors
commented
Feb 25, 2021
📌 Commit 356beb3 has been approved by |
…tebank Reword labels on E0308 involving async fn return type Fix for rust-lang#80658. When someone writes code like this: ```rust fn foo() -> u8 { async fn async_fn() -> () {} async_fn() } ``` And they try to compile it, they will see an error that looks like this: ```bash error[E0308]: mismatched types --> test.rs:4:5 | 1 | fn foo() -> u8 { | -- expected `u8` because of return type 2 | async fn async_fn() -> () {} | -- checked the `Output` of this `async fn`, found opaque type 3 | 4 | async_fn() | ^^^^^^^^^^ expected `u8`, found opaque type | = note: while checking the return type of this `async fn` = note: expected type `u8` found opaque type `impl Future` ```
…tebank Reword labels on E0308 involving async fn return type Fix for rust-lang#80658. When someone writes code like this: ```rust fn foo() -> u8 { async fn async_fn() -> () {} async_fn() } ``` And they try to compile it, they will see an error that looks like this: ```bash error[E0308]: mismatched types --> test.rs:4:5 | 1 | fn foo() -> u8 { | -- expected `u8` because of return type 2 | async fn async_fn() -> () {} | -- checked the `Output` of this `async fn`, found opaque type 3 | 4 | async_fn() | ^^^^^^^^^^ expected `u8`, found opaque type | = note: while checking the return type of this `async fn` = note: expected type `u8` found opaque type `impl Future` ```
…laumeGomez Rollup of 8 pull requests Successful merges: - rust-lang#81940 (Stabilize str_split_once) - rust-lang#82165 (Reword labels on E0308 involving async fn return type) - rust-lang#82456 (Replaced some unwrap_or and map_or with lazy variants) - rust-lang#82491 (Consider inexpensive inlining criteria first) - rust-lang#82506 (Properly account for non-shorthand pattern field in unused variable lint) - rust-lang#82535 (Set codegen thread names) - rust-lang#82545 (rustdoc: add optional woff2 versions of FiraSans.) - rust-lang#82549 (Revert "Update normalize.css to 8.0.1") Failed merges: r? `@ghost` `@rustbot` modify labels: rollup
Fix for #80658.
When someone writes code like this:
And they try to compile it, they will see an error that looks like this: