-
Notifications
You must be signed in to change notification settings - Fork 13k
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
type parameters expect camel case, but shouting case is also common #60570
Comments
Triage: Classifying as:
|
I think it is difficult to call this a bug. It is a limitation of allowing the "words" in camel case to be one letter long. (which is especially likely to occur in type parameters) I mean, to us, upper camel case means:
But consider the following: pub fn zip<A, B, IA, IB>(a: IA, b: IB) -> impl Iterator<Item=(A, B)>
where
IA: IntoIterator<Item=A>,
IB: IntoIterator<Item=B>,
{ ... } Here, I would assert that |
Oh wow! I didn't consider this. 😂 |
We discussed this in today's @rust-lang/lang meeting. In general, we felt like the compiler doesn't have enough information to know whether a string of all-caps characters is camel case of one-letter words/abbreviations or whether it's all-caps. I don't think we should encourage With that in mind, if someone proposed a PR that loosened the rules for CamelCase to permit ABCDECase, the team would be receptive to that. |
I am not sure why type parameters are checked to be upper camel case.
Type parameter names are not part of public API. Shouting case for type parameters is a convention followed by such popular crates as rayon, and it is the only way I know of to make something like the following not look confusing:
Furthermore, due to limitations of the check for upper camel case, you could write a whole crate using shouting case and not even know about the lint, because it will only hit you when you write an underscore:
Given how rarely underscores should be needed, it's tempting to just change this to
INTEGER1
so that it slips by unnoticed like the rest of the crate.The text was updated successfully, but these errors were encountered: