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

Do not suggest type parameter when followed by < #72640

Closed
dtolnay opened this issue May 27, 2020 · 0 comments · Fixed by #73320
Closed

Do not suggest type parameter when followed by < #72640

dtolnay opened this issue May 27, 2020 · 0 comments · Fixed by #73320
Assignees
Labels
A-diagnostics Area: Messages for errors, warnings, and lints A-suggestion-diagnostics Area: Suggestions generated by the compiler applied by `cargo fix` C-bug Category: This is a bug. 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

@dtolnay
Copy link
Member

dtolnay commented May 27, 2020

struct S {
    m: Vec<Hashmap<String, ()>>,
}
error[E0412]: cannot find type `Hashmap` in this scope
 --> src/main.rs:2:12
  |
1 | struct S {
  |         - help: you might be missing a type parameter: `<Hashmap>`
2 |     m: Vec<Hashmap<String, ()>>,
  |            ^^^^^^^ not found in this scope

Rustc should know that struct S<Hashmap> is not in the right direction because that still wouldn't make Hashmap<String, ()> a valid thing to write; type parameters can't have type parameters (yet??).

Separately, #70572 should also have prevented the suggestion in this case, but is an independent issue.

cc @estebank who worked on this recently in #68447.

@dtolnay dtolnay added A-diagnostics Area: Messages for errors, warnings, and lints C-bug Category: This is a bug. D-confusing Diagnostics: Confusing error or lint that should be reworked. D-invalid-suggestion Diagnostics: A structured suggestion resulting in incorrect code. and removed D-confusing Diagnostics: Confusing error or lint that should be reworked. labels May 27, 2020
@dtolnay dtolnay added the T-compiler Relevant to the compiler team, which will review and decide on the PR/issue. label May 27, 2020
@estebank estebank added the A-suggestion-diagnostics Area: Suggestions generated by the compiler applied by `cargo fix` label May 28, 2020
@estebank estebank self-assigned this Jun 13, 2020
Manishearth added a commit to Manishearth/rust that referenced this issue Jun 18, 2020
…vidtwco

Make new type param suggestion more targetted

Do not suggest new type param when encountering a missing type in an ADT
field with generic parameters.

Fix rust-lang#72640.
Manishearth added a commit to Manishearth/rust that referenced this issue Jun 18, 2020
…vidtwco

Make new type param suggestion more targetted

Do not suggest new type param when encountering a missing type in an ADT
field with generic parameters.

Fix rust-lang#72640.
@bors bors closed this as completed in 4606168 Jun 19, 2020
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 A-suggestion-diagnostics Area: Suggestions generated by the compiler applied by `cargo fix` C-bug Category: This is a bug. 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.

2 participants