Skip to content
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

E0308 for coroutines kinda cryptic #118954

Open
matthiaskrgr opened this issue Dec 14, 2023 · 2 comments
Open

E0308 for coroutines kinda cryptic #118954

matthiaskrgr opened this issue Dec 14, 2023 · 2 comments
Labels
A-coroutines Area: Coroutines A-diagnostics Area: Messages for errors, warnings, and lints F-coroutines `#![feature(coroutines)]` S-waiting-on-author Status: This is awaiting some action (such as code changes or more information) from the author. T-compiler Relevant to the compiler team, which will review and decide on the PR/issue.

Comments

@matthiaskrgr
Copy link
Member

Code

#![feature(coroutines)]
#![crate_type="lib"]

async fn async_fn() -> i32 {
    move || {
        yield 1_u32;
    }
}

Current output

error[E0308]: mismatched types
 --> 94BA3E9349D8E32F911462C954A9A278963282E62BF874B0EED4F13C0EFFE468.rs:5:5
  |
5 | /     move || {
6 | |         yield 1_u32;
7 | |     }
  | |_____^ expected `i32`, found coroutine
  |
  = note:   expected type `i32`
          found coroutine `{coroutine@94BA3E9349D8E32F911462C954A9A278963282E62BF874B0EED4F13C0EFFE468.rs:5:5: 5:12}`

error: aborting due to 1 previous error

For more information about this error, try `rustc --explain E0308`.

Desired output

`found coroutine<u32>`   or something like that?

Rationale and extra context

No response

Other cases

No response

Anything else?

No response

@matthiaskrgr matthiaskrgr added A-diagnostics Area: Messages for errors, warnings, and lints T-compiler Relevant to the compiler team, which will review and decide on the PR/issue. A-coroutines Area: Coroutines A-suggestion-diagnostics Area: Suggestions generated by the compiler applied by `cargo fix` F-coroutines `#![feature(coroutines)]` labels Dec 14, 2023
@rustbot rustbot added the needs-triage This issue may need triage. Remove it if it has been sufficiently triaged. label Dec 14, 2023
@matthiaskrgr matthiaskrgr removed the A-suggestion-diagnostics Area: Suggestions generated by the compiler applied by `cargo fix` label Dec 14, 2023
@compiler-errors
Copy link
Member

compiler-errors commented Dec 15, 2023

This is no worse than a closure error.

error[E0308]: mismatched types
 --> src/lib.rs:2:5
  |
2 | /     move || {
3 | |         
4 | |     }
  | |_____^ expected `i32`, found closure
  |
  = note: expected type `i32`
          found closure `{closure@src/lib.rs:2:5: 2:12}`

Is it worse because you generate files with wild names like 94BA3E9349D8E32F911462C954A9A278963282E62BF874B0EED4F13C0EFFE468.rs?

@compiler-errors
Copy link
Member

compiler-errors commented Dec 15, 2023

That being said, if you think closure type names are cryptic ({closure@FILE:LL:CC}), then that's a separate issue. Probably one that has had discussions/bikeshedding in the past?

@saethlin saethlin added S-waiting-on-author Status: This is awaiting some action (such as code changes or more information) from the author. and removed needs-triage This issue may need triage. Remove it if it has been sufficiently triaged. labels Dec 16, 2023
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
A-coroutines Area: Coroutines A-diagnostics Area: Messages for errors, warnings, and lints F-coroutines `#![feature(coroutines)]` S-waiting-on-author Status: This is awaiting some action (such as code changes or more information) from the author. T-compiler Relevant to the compiler team, which will review and decide on the PR/issue.
Projects
None yet
Development

No branches or pull requests

4 participants