Skip to content
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

pnkfelix
Copy link
Member

r? anyone

Address scariest part of #7526 by adding a new more specific lint (that is set to warn by default, rather than allow).

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()) {
Copy link
Member

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.

Copy link
Member Author

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...

@huonw
Copy link
Member

huonw commented Oct 1, 2013

I'm probably missing some subtlety here, but is there are reason this didn't just go in middle::lint as a Visitor that just overrides visit_pat and checks the PatIdents?

@pnkfelix
Copy link
Member Author

pnkfelix commented Oct 1, 2013

@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.

bors added a commit that referenced this pull request Oct 2, 2013
…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).
@bors bors closed this Oct 2, 2013
@bors bors merged commit 2461b31 into rust-lang:master Oct 2, 2013
flip1995 pushed a commit to flip1995/rust that referenced this pull request Oct 20, 2022
…=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
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

4 participants