-
-
Notifications
You must be signed in to change notification settings - Fork 14.8k
Shorter type-names on type errors #50310
Copy link
Copy link
Closed
Labels
A-diagnosticsArea: Messages for errors, warnings, and lintsArea: Messages for errors, warnings, and lintsC-enhancementCategory: An issue proposing an enhancement or a PR with one.Category: An issue proposing an enhancement or a PR with one.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.
Metadata
Metadata
Assignees
Labels
A-diagnosticsArea: Messages for errors, warnings, and lintsArea: Messages for errors, warnings, and lintsC-enhancementCategory: An issue proposing an enhancement or a PR with one.Category: An issue proposing an enhancement or a PR with one.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.
Type
Fields
Give feedbackNo fields configured for issues without a type.
Type errors (
E0308) are a common occurrence in rustc. Whenever I confuse myself about the type of something, I tend to assign it to somex: i32and let the compiler blame me with a hint about what typexactually is. Thenote-section attached to the error message contains the fully qualified type name, which is technically as correct as one can get. However, this also produces a lot of clutter, because the type-name that I'm actually interested in is much more concise if types in scope of the offending statement are taken into account. For example:The
notesaysAgain, while this is as precise as it can get, most of this is just clutter, especially with deeply nested types: I know that
HashMapis fromstd::collections, I also know thatOptionrefers tostd::option::Option. If I had some other type shadowing those names, I'd be aware of it. Reading the note, I have to demangle the type-name towhich is what the type-name would be if I wanted to write it down, considering all the
uses.Could we at least have an option (or an extra note) for
E0308where the type-names get uncluttered by considering the types that are in scope for the offending statement? This would reduce the intellectual burden and may enable one to just copy&paste the type-name from the note.