-
Notifications
You must be signed in to change notification settings - Fork 13.6k
Open
Labels
A-diagnosticsArea: Messages for errors, warnings, and lintsArea: Messages for errors, warnings, and lintsA-resolveArea: Name/path resolution done by `rustc_resolve` specificallyArea: Name/path resolution done by `rustc_resolve` specificallyD-papercutDiagnostics: An error or lint that needs small tweaks.Diagnostics: An error or lint that needs small tweaks.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
Code
pub fn do_stuff() -> Option<ForgotToImport> {
None
}
Current output
error[E0412]: cannot find type `ForgotToImport` in this scope
--> src/lib.rs:1:29
|
1 | pub fn do_stuff() -> Option<ForgotToImport> {
| ^^^^^^^^^^^^^^ not found in this scope
|
help: you might be missing a type parameter
|
1 | pub fn do_stuff<ForgotToImport>() -> Option<ForgotToImport> {
| ++++++++++++++++
Desired output
error[E0412]: cannot find type `ForgotToImport` in this scope
--> src/lib.rs:1:29
|
1 | pub fn do_stuff() -> Option<ForgotToImport> {
| ^^^^^^^^^^^^^^ not found in this scope
Rationale and extra context
Type parameters are rarely this long, so rustc's guess seems like a poor fit. Could rustc treat longer names as unlikely to be type parameters?
Another option would be to skip this suggestion if the type name is CamelCase.
Other cases
Rust Version
$ rustc --version --verbose
rustc 1.86.0 (05f9846f8 2025-03-31)
binary: rustc
commit-hash: 05f9846f893b09a1be1fc8560e33fc3c815cfecb
commit-date: 2025-03-31
host: x86_64-unknown-linux-gnu
release: 1.86.0
LLVM version: 19.1.7
Anything else?
No response
Metadata
Metadata
Assignees
Labels
A-diagnosticsArea: Messages for errors, warnings, and lintsArea: Messages for errors, warnings, and lintsA-resolveArea: Name/path resolution done by `rustc_resolve` specificallyArea: Name/path resolution done by `rustc_resolve` specificallyD-papercutDiagnostics: An error or lint that needs small tweaks.Diagnostics: An error or lint that needs small tweaks.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.