-
Notifications
You must be signed in to change notification settings - Fork 12.9k
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
Unify non-snake-case lints and non-uppercase statics lints; add lint groups #15773
Conversation
I'm a little uneasy about the continued proliferation of micro-lints, especially for various style criteria. I think I would rather push lints like these all under the same "non snake case" lint rather than a "non snake case X" lint. |
I agree—the level of control over style lints right now is far too fine-grained. Do you think it would be a good idea to unify some other lints (like (It should be noted that right now |
OK, I’ve merged the uppercase and snake case lints together. I’m not sure if this counts as a breaking change or not. |
Thanks @P1start! I do think that this needs a cc @brson, @aturon, I like the direction this is going, I'm not sure if we want to go all the way towards just one |
Maybe we could have umbrella lints? So one still have fine-grained control of individual things, but the 'common' cases are covered by lints like |
@huonw Maybe that could be done with a normal attribute that expands to a number of lint attributes? So something like |
I don't like it; it's a whole new attribute to remember and use, and isn't very extensible, e.g. what if one wants |
Perhaps the most flexible solution would be to allow lints to have parameters. All the style lints could be put into one lint, with parameters for fine-tuning. So |
Yes @huonw I think that may be a good direction to start going in. Messaging that in terms of error messages may get tricky, but I think it may be good to have. |
Should I add umbrella lints ( |
Well, I’ve added lint groups/umbrella lints. I’ve also added two built-in lint groups named |
@P1start this looks pretty good to me, I'd like to gain a few more opinions about umbrella lints, however, because this is a pretty big feature for the compiler. |
My 2c: I think umbrella lints are a very useful idea, and I don't see a lot of downside. So +1 from me! |
Not quite +1: see http://discuss.rust-lang.org/t/umbrella-lints/307 (TLDR -- I am concerned about backwards compat) |
This was discussed in yesterday's meeting and we decided to merge it, thanks for being patient @P1start! |
Updated; tests pass locally. I should probably also note that this change makes |
677333f
to
7282c4d
Compare
Argh sorry @P1start, this totally fell under the radar! Feel free to ping PRs if they don't seem to have much activity to spur us into action! |
This unifies the `non_snake_case_functions` and `uppercase_variables` lints into one lint, `non_snake_case`. It also now checks for non-snake-case modules. This also extends the non-camel-case types lint to check type parameters, and merges the `non_uppercase_pattern_statics` lint into the `non_uppercase_statics` lint. Because the `uppercase_variables` lint is now part of the `non_snake_case` lint, all non-snake-case variables that start with lowercase characters (such as `fooBar`) will now trigger the `non_snake_case` lint. New code should be updated to use the new `non_snake_case` lint instead of the previous `non_snake_case_functions` and `uppercase_variables` lints. All use of the `non_uppercase_pattern_statics` should be replaced with the `non_uppercase_statics` lint. Any code that previously contained non-snake-case module or variable names should be updated to use snake case names or disable the `non_snake_case` lint. Any code with non-camel-case type parameters should be changed to use camel case or disable the `non_camel_case_types` lint. [breaking-change]
This adds support for lint groups to the compiler. Lint groups are a way of grouping a number of lints together under one name. For example, this also defines a default lint for naming conventions, named `bad_style`. Writing `#[allow(bad_style)]` is equivalent to writing `#[allow(non_camel_case_types, non_snake_case, non_uppercase_statics)]`. These lint groups can also be defined as a compiler plugin using the new `Registry::register_lint_group` method. This also adds two built-in lint groups, `bad_style` and `unused`. The contents of these groups can be seen by running `rustc -W help`.
Updated again; tests pass locally. |
This unifies the `non_snake_case_functions` and `uppercase_variables` lints into one lint, `non_snake_case`. It also now checks for non-snake-case modules. This also extends the non-camel-case types lint to check type parameters, and merges the `non_uppercase_pattern_statics` lint into the `non_uppercase_statics` lint. Because the `uppercase_variables` lint is now part of the `non_snake_case` lint, all non-snake-case variables that start with lowercase characters (such as `fooBar`) will now trigger the `non_snake_case` lint. New code should be updated to use the new `non_snake_case` lint instead of the previous `non_snake_case_functions` and `uppercase_variables` lints. All use of the `non_uppercase_pattern_statics` should be replaced with the `non_uppercase_statics` lint. Any code that previously contained non-snake-case module or variable names should be updated to use snake case names or disable the `non_snake_case` lint. Any code with non-camel-case type parameters should be changed to use camel case or disable the `non_camel_case_types` lint. This also adds support for lint groups to the compiler. Lint groups are a way of grouping a number of lints together under one name. For example, this also defines a default lint for naming conventions, named `bad_style`. Writing `#[allow(bad_style)]` is equivalent to writing `#[allow(non_camel_case_types, non_snake_case, non_uppercase_statics)]`. These lint groups can also be defined as a compiler plugin using the new `Registry::register_lint_group` method. This also adds two built-in lint groups, `bad_style` and `unused`. The contents of these groups can be seen by running `rustc -W help`. [breaking-change]
Signed-off-by: Peter Atashian <retep998@gmail.com>
Signed-off-by: Peter Atashian <retep998@gmail.com>
This unifies the
non_snake_case_functions
anduppercase_variables
lints into one lint,non_snake_case
. It also now checks for non-snake-case modules. This also extends the non-camel-case types lint to check type parameters, and merges thenon_uppercase_pattern_statics
lint into thenon_uppercase_statics
lint.Because the
uppercase_variables
lint is now part of thenon_snake_case
lint, all non-snake-case variables that start with lowercase characters (such asfooBar
) will now trigger thenon_snake_case
lint.New code should be updated to use the new
non_snake_case
lint instead of the previousnon_snake_case_functions
anduppercase_variables
lints. All use of thenon_uppercase_pattern_statics
should be replaced with thenon_uppercase_statics
lint. Any code that previously contained non-snake-case module or variable names should be updated to use snake case names or disable thenon_snake_case
lint. Any code with non-camel-case type parameters should be changed to use camel case or disable thenon_camel_case_types
lint.This also adds support for lint groups to the compiler. Lint groups are a way of grouping a number of lints together under one name. For example, this also defines a default lint for naming conventions, named
bad_style
. Writing#[allow(bad_style)]
is equivalent to writing#[allow(non_camel_case_types, non_snake_case, non_uppercase_statics)]
. These lint groups can also be defined as a compiler plugin using the newRegistry::register_lint_group
method.This also adds two built-in lint groups,
bad_style
andunused
. The contents of these groups can be seen by runningrustc -W help
.[breaking-change]