Skip to content

Commit c4b2fed

Browse files
authored
A few updates to the lint set (#122)
Having used [`clippy::default_trait_access`](https://rust-lang.github.io/rust-clippy/stable/index.html#default_trait_access) as an editor lint, I'm really happy with it. It also only ever makes extremely local suggestions (making addressing it when writing a change trivial), and significantly improves readability in a lot of cases. It's also something which I've now found myself suggesting regularly in PR reviews, as better style. As such, I'm proposing that we move this into the proper lint set. Separately, [`unused_qualifications`](https://doc.rust-lang.org/rustc/lints/listing/allowed-by-default.html#unused-qualifications) is good for consistency (if you see `Rect` and `kurbo::Rect` next to each other, you might reasonably assume that they are different types). As such, I'm also proposing that we move this into the "proper" lint set out of the periodic lints. This proposal is more marginal, and I'm happy to demote it back to a periodic lint if there's pushback. Thirdly, I'm proposing removed the editor lints as a class; I don't think anyone ever used them, and the theory that you can make drive-by style fixes in otherwise unrelated PRs was never sound.
1 parent 983faa1 commit c4b2fed

1 file changed

Lines changed: 4 additions & 14 deletions

File tree

content/wiki/canonical_lints.md

Lines changed: 4 additions & 14 deletions
Original file line numberDiff line numberDiff line change
@@ -11,7 +11,7 @@ All Linebender projects should include the following set of lints:
1111
# This one may vary depending on the project.
1212
rust.unsafe_code = "forbid"
1313

14-
# LINEBENDER LINT SET - Cargo.toml - v6.1
14+
# LINEBENDER LINT SET - Cargo.toml - v7
1515
# See https://linebender.org/wiki/canonical-lints/
1616
rust.keyword_idents_2024 = "forbid"
1717
rust.non_ascii_idents = "forbid"
@@ -27,12 +27,14 @@ rust.unreachable_pub = "warn"
2727
rust.unused_import_braces = "warn"
2828
rust.unused_lifetimes = "warn"
2929
rust.unused_macro_rules = "warn"
30+
rust.unused_qualifications = "warn"
3031

3132
clippy.too_many_arguments = "allow"
3233

3334
clippy.allow_attributes_without_reason = "warn"
3435
clippy.cast_possible_truncation = "warn"
3536
clippy.collection_is_never_read = "warn"
37+
clippy.default_trait_access = "warn"
3638
clippy.dbg_macro = "warn"
3739
clippy.debug_assert_with_mut_call = "warn"
3840
clippy.doc_markdown = "warn"
@@ -104,34 +106,22 @@ These lints can be run occasionally, such as when releases are near, to improve
104106
let_underscore_drop
105107
single_use_lifetimes
106108
unit_bindings
107-
unused_qualifications
108109
variant_size_differences
109110
110111
clippy::allow_attributes
111112
clippy::large_include_file
112113
clippy::match_same_arms
113114
clippy::partial_pub_fields
114-
clippy::default_trait_access
115115
clippy::return_self_not_must_use
116116
clippy::shadow_unrelated
117117
```
118118

119119
As a runnable command, there are:
120120

121121
```sh
122-
cargo clippy -- -W let_underscore_drop -W single_use_lifetimes -W unit_bindings -W unused_qualifications -W variant_size_differences -W clippy::large_include_file -W clippy::match_same_arms -W clippy::partial_pub_fields -W clippy::default_trait_access -W clippy::return_self_not_must_use -W clippy::shadow_unrelated
122+
cargo clippy -- -W let_underscore_drop -W single_use_lifetimes -W unit_bindings -W variant_size_differences -W clippy::large_include_file -W clippy::match_same_arms -W clippy::partial_pub_fields -W clippy::return_self_not_must_use -W clippy::shadow_unrelated
123123
```
124124

125-
You may also wish to enable some of these lints specifically in your editor, to improve as you go.
126-
The ones which are trivial to do this for are below (as the changes it will propose are always very small):
127-
128-
```sh
129-
cargo clippy -- -W single_use_lifetimes -W unit_bindings -W unused_qualifications -W clippy::allow_attributes -W clippy::default_trait_access
130-
```
131-
132-
If there are many failures of one of these lints across the project, a separate PR would be recommended.
133-
Otherwise, resolving these in a drive-by manner is fine.
134-
135125
### Pedantic
136126

137127
You may occasionally want to run `cargo clippy` with `clippy::pedantic` on the codebase, which will cast a very wide net and catch a lot of very minor issues.

0 commit comments

Comments
 (0)