-
-
Notifications
You must be signed in to change notification settings - Fork 14.8k
Warn if type-name in parameter-position #67069
Copy link
Copy link
Open
Labels
A-diagnosticsArea: Messages for errors, warnings, and lintsArea: Messages for errors, warnings, and lintsA-lintsArea: Lints (warnings about flaws in source code) such as unused_mut.Area: Lints (warnings about flaws in source code) such as unused_mut.C-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.T-langRelevant to the language teamRelevant to the language team
Metadata
Metadata
Assignees
Labels
A-diagnosticsArea: Messages for errors, warnings, and lintsArea: Messages for errors, warnings, and lintsA-lintsArea: Lints (warnings about flaws in source code) such as unused_mut.Area: Lints (warnings about flaws in source code) such as unused_mut.C-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.T-langRelevant to the language teamRelevant to the language team
Type
Fields
Give feedbackNo fields configured for issues without a type.
I was surprised that one can confuse himself like in the cooked-up example below: Specifying a concrete type for a parameter on an
impldoes what one expects. This might lead to the expectation that you can specify a concrete type for a parameter on anfn, which is not the case:Here,
Stringdoes not refer to the typeStringbut is still a generic parameter, now namedStringinstead ofH.If we don't specify the
Display-bound, the compiler even helpfully suggests to add the requirementString: Display, which we can do right away. We can usefn bar<u32>(...)and the compiler will warn thatu32should be upper-cased.Maybe the compiler could warn if a parameter is given the name of a type that is in scope? Something to the tune of