-
Notifications
You must be signed in to change notification settings - Fork 13.6k
Closed
Labels
A-diagnosticsArea: Messages for errors, warnings, and lintsArea: Messages for errors, warnings, and lintsA-suggestion-diagnosticsArea: Suggestions generated by the compiler applied by `cargo fix`Area: Suggestions generated by the compiler applied by `cargo fix`C-bugCategory: This is a bug.Category: This is a bug.D-verboseDiagnostics: Too much output caused by a single piece of incorrect code.Diagnostics: Too much output caused by a single piece of incorrect code.T-compilerRelevant to the compiler team, which will review and decide on the PR/issue.Relevant to the compiler team, which will review and decide on the PR/issue.
Description
The following code now emits a suggestion to add a type parameter (since #68447 in 1.42):
pub struct S {
pub f: Option<PathBuf>
}
Emits:
error[E0412]: cannot find type `PathBuf` in this scope
--> src/lib.rs:2:19
|
2 | pub f: Option<PathBuf>
| ^^^^^^^ not found in this scope
|
help: possible candidate is found in another module, you can import it into scope
|
1 | use std::path::PathBuf;
|
help: you might be missing a type parameter
|
1 | pub struct S<PathBuf> {
| ^^^^^^^^^
The suggestion to add <PathBuf>
is clearly wrong (in my eyes), and I feel like I am seeing this suggestion a lot.
Perhaps, if there is already a "possible candidate import" suggestion, it could skip the suggestion to add a type parameter? Or maybe some other heuristic to dial back how often it shows up?
(BTW, it is a great suggestion when it applies, but more often than not I'm getting a wrong hint.)
RalfJung
Metadata
Metadata
Assignees
Labels
A-diagnosticsArea: Messages for errors, warnings, and lintsArea: Messages for errors, warnings, and lintsA-suggestion-diagnosticsArea: Suggestions generated by the compiler applied by `cargo fix`Area: Suggestions generated by the compiler applied by `cargo fix`C-bugCategory: This is a bug.Category: This is a bug.D-verboseDiagnostics: Too much output caused by a single piece of incorrect code.Diagnostics: Too much output caused by a single piece of incorrect code.T-compilerRelevant to the compiler team, which will review and decide on the PR/issue.Relevant to the compiler team, which will review and decide on the PR/issue.