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

Incorrect suggestion when type annotation on turbofished enum is needed #100137

Closed
5225225 opened this issue Aug 4, 2022 · 0 comments · Fixed by #100986
Closed

Incorrect suggestion when type annotation on turbofished enum is needed #100137

5225225 opened this issue Aug 4, 2022 · 0 comments · Fixed by #100986
Assignees
Labels
A-diagnostics Area: Messages for errors, warnings, and lints D-invalid-suggestion Diagnostics: A structured suggestion resulting in incorrect code. T-compiler Relevant to the compiler team, which will review and decide on the PR/issue.

Comments

@5225225
Copy link
Contributor

5225225 commented Aug 4, 2022

Given the following code: https://play.rust-lang.org/?version=nightly&mode=release&edition=2021&gist=b9b341939839ec733bf081c5ddf86e5b

enum OhNo<T, U> {
  A(T),
  B(U),
  C,
}

fn uwu() {
    OhNo::C::<u32, _>;
}

The current output is:

Compiling playground v0.0.1 (/playground)
error[E0282]: type annotations needed
 --> src/lib.rs:8:5
  |
8 |     OhNo::C::<u32, _>;
  |     ^^^^^^^^^^^^^^^^^ cannot infer type of the type parameter `U` declared on the enum `OhNo`
  |
help: consider specifying the generic arguments
  |
8 |     OhNo::<u32, _>::C::<u32, _>;
  |         ++++++++++

For more information about this error, try `rustc --explain E0282`.
error: could not compile `playground` due to previous error

But applying this causes an error, saying that C doesn't allow type arguments.

This happens on nightly and beta, but not on stable. I'm assuming the "consider specifying the generic arguments" was added recently.

I don't think we need the help here, because the generic arguments are already specified.

@rustbot label +D-invalid-suggestion

@5225225 5225225 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. labels Aug 4, 2022
@rustbot rustbot added the D-invalid-suggestion Diagnostics: A structured suggestion resulting in incorrect code. label Aug 4, 2022
@TaKO8Ki TaKO8Ki self-assigned this Aug 4, 2022
@bors bors closed this as completed in f8f5019 Oct 5, 2022
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
A-diagnostics Area: Messages for errors, warnings, and lints D-invalid-suggestion Diagnostics: A structured suggestion resulting in incorrect code. T-compiler Relevant to the compiler team, which will review and decide on the PR/issue.
Projects
None yet
Development

Successfully merging a pull request may close this issue.

3 participants