-
Notifications
You must be signed in to change notification settings - Fork 13.3k
Issue7526 attempt to catch non uppercase statics in match patterns #9638
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
Issue7526 attempt to catch non uppercase statics in match patterns #9638
Conversation
This tries to warn about code like: ```rust match (0,0) { (0, aha) => { ... }, ... } ``` where `aha` is actually a static constant, not a binding.
about constants that are (non-trivial) paths rather than just identifiers, regardless of what case their characters are.
// last identifier alone is right choice for this lint. | ||
let ident = path.segments.last().identifier; | ||
let s = cx.tcx.sess.str_of(ident); | ||
if s.iter().any(|c| c.is_lowercase()) { |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I would think that constants of the form CamelCase
are probably not local variables, but I suppose that the non_uppercase_statics
lint does this same check, so oh well.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Yeah I thought about just looking at the first character alone, but I don't see the harm in nudging people towards the all-caps convention...
This is to clarify that the lint is checking for THIS_THING and not This.
I'm probably missing some subtlety here, but is there are reason this didn't just go in |
@huonw I don't have any reason beyond this was the first thing I managed to actually get working, and that there is already a check in the same place for a slightly different property of match arms. I'll check whether refactoring the code in the manner you mention is possible. |
…nuc-statics-in-match-patterns, r=alexcrichton r? anyone Address scariest part of #7526 by adding a new more specific lint (that is set to warn by default, rather than allow).
…=llogiq Add a suggestion and a note about orphan rules for `from_over_into` Adds a machine applicable suggestion to convert the `Into` impl into a `From` one to `from_over_into` Also adds a note explaining that `impl From<Local> for Foreign` is fine if the `Into` type is foreign Closes rust-lang#7444 Addresses half of rust-lang#9638 changelog: [`from_over_into`] Add a suggestion and a note about orphan rules
r? anyone
Address scariest part of #7526 by adding a new more specific lint (that is set to warn by default, rather than allow).