Skip to content

Commit 7d4df2d

Browse files
committed
Auto merge of #107386 - flip1995:clippyup, r=Manishearth
Update Clippy r? `@Manishearth`
2 parents ef98292 + c71062a commit 7d4df2d

Some content is hidden

Large Commits have some content hidden by default. Use the searchbox below for content that may be hidden.

58 files changed

+2216
-258
lines changed

Cargo.lock

+4-4
Original file line numberDiff line numberDiff line change
@@ -724,7 +724,7 @@ dependencies = [
724724

725725
[[package]]
726726
name = "clippy"
727-
version = "0.1.68"
727+
version = "0.1.69"
728728
dependencies = [
729729
"clippy_lints",
730730
"clippy_utils",
@@ -766,7 +766,7 @@ dependencies = [
766766

767767
[[package]]
768768
name = "clippy_lints"
769-
version = "0.1.68"
769+
version = "0.1.69"
770770
dependencies = [
771771
"cargo_metadata 0.14.0",
772772
"clippy_utils",
@@ -789,7 +789,7 @@ dependencies = [
789789

790790
[[package]]
791791
name = "clippy_utils"
792-
version = "0.1.68"
792+
version = "0.1.69"
793793
dependencies = [
794794
"arrayvec",
795795
"if_chain",
@@ -1168,7 +1168,7 @@ checksum = "a0afaad2b26fa326569eb264b1363e8ae3357618c43982b3f285f0774ce76b69"
11681168

11691169
[[package]]
11701170
name = "declare_clippy_lint"
1171-
version = "0.1.68"
1171+
version = "0.1.69"
11721172
dependencies = [
11731173
"itertools",
11741174
"quote",

src/tools/clippy/.github/workflows/clippy_bors.yml

+5
Original file line numberDiff line numberDiff line change
@@ -157,6 +157,11 @@ jobs:
157157
- name: Test metadata collection
158158
run: cargo collect-metadata
159159

160+
- name: Test lint_configuration.md is up-to-date
161+
run: |
162+
echo "run \`cargo collect-metadata\` if this fails"
163+
git update-index --refresh
164+
160165
integration_build:
161166
needs: changelog
162167
runs-on: ubuntu-latest

src/tools/clippy/CHANGELOG.md

+197-2
Original file line numberDiff line numberDiff line change
@@ -6,11 +6,204 @@ document.
66

77
## Unreleased / Beta / In Rust Nightly
88

9-
[4f142aa1...master](https://github.com/rust-lang/rust-clippy/compare/4f142aa1...master)
9+
[d822110d...master](https://github.com/rust-lang/rust-clippy/compare/d822110d...master)
10+
11+
## Rust 1.67
12+
13+
Current stable, released 2023-01-26
14+
15+
[4f142aa1...d822110d](https://github.com/rust-lang/rust-clippy/compare/4f142aa1...d822110d)
16+
17+
### New Lints
18+
19+
* [`seek_from_current`]
20+
[#9681](https://github.com/rust-lang/rust-clippy/pull/9681)
21+
* [`from_raw_with_void_ptr`]
22+
[#9690](https://github.com/rust-lang/rust-clippy/pull/9690)
23+
* [`misnamed_getters`]
24+
[#9770](https://github.com/rust-lang/rust-clippy/pull/9770)
25+
* [`seek_to_start_instead_of_rewind`]
26+
[#9667](https://github.com/rust-lang/rust-clippy/pull/9667)
27+
* [`suspicious_xor_used_as_pow`]
28+
[#9506](https://github.com/rust-lang/rust-clippy/pull/9506)
29+
* [`unnecessary_safety_doc`]
30+
[#9822](https://github.com/rust-lang/rust-clippy/pull/9822)
31+
* [`unchecked_duration_subtraction`]
32+
[#9570](https://github.com/rust-lang/rust-clippy/pull/9570)
33+
* [`manual_is_ascii_check`]
34+
[#9765](https://github.com/rust-lang/rust-clippy/pull/9765)
35+
* [`unnecessary_safety_comment`]
36+
[#9851](https://github.com/rust-lang/rust-clippy/pull/9851)
37+
* [`let_underscore_future`]
38+
[#9760](https://github.com/rust-lang/rust-clippy/pull/9760)
39+
* [`manual_let_else`]
40+
[#8437](https://github.com/rust-lang/rust-clippy/pull/8437)
41+
42+
### Moves and Deprecations
43+
44+
* Moved [`uninlined_format_args`] to `style` (Now warn-by-default)
45+
[#9865](https://github.com/rust-lang/rust-clippy/pull/9865)
46+
* Moved [`needless_collect`] to `nursery` (Now allow-by-default)
47+
[#9705](https://github.com/rust-lang/rust-clippy/pull/9705)
48+
* Moved [`or_fun_call`] to `nursery` (Now allow-by-default)
49+
[#9829](https://github.com/rust-lang/rust-clippy/pull/9829)
50+
* Uplifted [`let_underscore_lock`] into rustc
51+
[#9697](https://github.com/rust-lang/rust-clippy/pull/9697)
52+
* Uplifted [`let_underscore_drop`] into rustc
53+
[#9697](https://github.com/rust-lang/rust-clippy/pull/9697)
54+
* Moved [`bool_to_int_with_if`] to `pedantic` (Now allow-by-default)
55+
[#9830](https://github.com/rust-lang/rust-clippy/pull/9830)
56+
* Move `index_refutable_slice` to `pedantic` (Now warn-by-default)
57+
[#9975](https://github.com/rust-lang/rust-clippy/pull/9975)
58+
* Moved [`manual_clamp`] to `nursery` (Now allow-by-default)
59+
[#10101](https://github.com/rust-lang/rust-clippy/pull/10101)
60+
61+
### Enhancements
62+
63+
* The scope of `#![clippy::msrv]` is now tracked correctly
64+
[#9924](https://github.com/rust-lang/rust-clippy/pull/9924)
65+
* `#[clippy::msrv]` can now be used as an outer attribute
66+
[#9860](https://github.com/rust-lang/rust-clippy/pull/9860)
67+
* Clippy will now avoid Cargo's cache, if `Cargo.toml` or `clippy.toml` have changed
68+
[#9707](https://github.com/rust-lang/rust-clippy/pull/9707)
69+
* [`uninlined_format_args`]: Added a new config `allow-mixed-uninlined-format-args` to allow the
70+
lint, if only some arguments can be inlined
71+
[#9865](https://github.com/rust-lang/rust-clippy/pull/9865)
72+
* [`needless_lifetimes`]: Now provides suggests for individual lifetimes
73+
[#9743](https://github.com/rust-lang/rust-clippy/pull/9743)
74+
* [`needless_collect`]: Now detects needless `is_empty` and `contains` calls
75+
[#8744](https://github.com/rust-lang/rust-clippy/pull/8744)
76+
* [`blanket_clippy_restriction_lints`]: Now lints, if `clippy::restriction` is enabled via the
77+
command line arguments
78+
[#9755](https://github.com/rust-lang/rust-clippy/pull/9755)
79+
* [`mutable_key_type`]: Now has the `ignore-interior-mutability` configuration, to add types which
80+
should be ignored by the lint
81+
[#9692](https://github.com/rust-lang/rust-clippy/pull/9692)
82+
* [`uninlined_format_args`]: Now works for multiline `format!` expressions
83+
[#9945](https://github.com/rust-lang/rust-clippy/pull/9945)
84+
* [`cognitive_complexity`]: Now works for async functions
85+
[#9828](https://github.com/rust-lang/rust-clippy/pull/9828)
86+
[#9836](https://github.com/rust-lang/rust-clippy/pull/9836)
87+
* [`vec_box`]: Now avoids an off-by-one error when using the `vec-box-size-threshold` configuration
88+
[#9848](https://github.com/rust-lang/rust-clippy/pull/9848)
89+
* [`never_loop`]: Now correctly handles breaks in nested labeled blocks
90+
[#9858](https://github.com/rust-lang/rust-clippy/pull/9858)
91+
[#9837](https://github.com/rust-lang/rust-clippy/pull/9837)
92+
* [`disallowed_methods`], [`disallowed_types`], [`disallowed_macros`]: Now correctly resolve
93+
paths, if a crate is used multiple times with different versions
94+
[#9800](https://github.com/rust-lang/rust-clippy/pull/9800)
95+
* [`disallowed_methods`]: Can now be used for local methods
96+
[#9800](https://github.com/rust-lang/rust-clippy/pull/9800)
97+
* [`print_stdout`], [`print_stderr`]: Can now be enabled in test with the `allow-print-in-tests`
98+
config value
99+
[#9797](https://github.com/rust-lang/rust-clippy/pull/9797)
100+
* [`from_raw_with_void_ptr`]: Now works for `Rc`, `Arc`, `alloc::rc::Weak` and
101+
`alloc::sync::Weak` types.
102+
[#9700](https://github.com/rust-lang/rust-clippy/pull/9700)
103+
* [`needless_borrowed_reference`]: Now works for struct and tuple patterns with wildcards
104+
[#9855](https://github.com/rust-lang/rust-clippy/pull/9855)
105+
* [`or_fun_call`]: Now supports `map_or` methods
106+
[#9689](https://github.com/rust-lang/rust-clippy/pull/9689)
107+
* [`unwrap_used`], [`expect_used`]: No longer lints in test code
108+
[#9686](https://github.com/rust-lang/rust-clippy/pull/9686)
109+
* [`fn_params_excessive_bools`]: Is now emitted with the lint level at the linted function
110+
[#9698](https://github.com/rust-lang/rust-clippy/pull/9698)
111+
112+
### False Positive Fixes
113+
114+
* [`new_ret_no_self`]: No longer lints when `impl Trait<Self>` is returned
115+
[#9733](https://github.com/rust-lang/rust-clippy/pull/9733)
116+
* [`unnecessary_lazy_evaluations`]: No longer lints, if the type has a significant drop
117+
[#9750](https://github.com/rust-lang/rust-clippy/pull/9750)
118+
* [`option_if_let_else`]: No longer lints, if any arm has guard
119+
[#9747](https://github.com/rust-lang/rust-clippy/pull/9747)
120+
* [`explicit_auto_deref`]: No longer lints, if the target type is a projection with generic
121+
arguments
122+
[#9813](https://github.com/rust-lang/rust-clippy/pull/9813)
123+
* [`unnecessary_to_owned`]: No longer lints, if the suggestion effects types
124+
[#9796](https://github.com/rust-lang/rust-clippy/pull/9796)
125+
* [`needless_borrow`]: No longer lints, if the suggestion is affected by `Deref`
126+
[#9674](https://github.com/rust-lang/rust-clippy/pull/9674)
127+
* [`unused_unit`]: No longer lints, if lifetimes are bound to the return type
128+
[#9849](https://github.com/rust-lang/rust-clippy/pull/9849)
129+
* [`mut_mut`]: No longer lints cases with unsized mutable references
130+
[#9835](https://github.com/rust-lang/rust-clippy/pull/9835)
131+
* [`bool_to_int_with_if`]: No longer lints in const context
132+
[#9738](https://github.com/rust-lang/rust-clippy/pull/9738)
133+
* [`use_self`]: No longer lints in macros
134+
[#9704](https://github.com/rust-lang/rust-clippy/pull/9704)
135+
* [`unnecessary_operation`]: No longer lints, if multiple macros are involved
136+
[#9981](https://github.com/rust-lang/rust-clippy/pull/9981)
137+
* [`allow_attributes_without_reason`]: No longer lints inside external macros
138+
[#9630](https://github.com/rust-lang/rust-clippy/pull/9630)
139+
* [`question_mark`]: No longer lints for `if let Err()` with an `else` branch
140+
[#9722](https://github.com/rust-lang/rust-clippy/pull/9722)
141+
* [`unnecessary_cast`]: No longer lints if the identifier and cast originate from different macros
142+
[#9980](https://github.com/rust-lang/rust-clippy/pull/9980)
143+
* [`arithmetic_side_effects`]: Now detects operations with associated constants
144+
[#9592](https://github.com/rust-lang/rust-clippy/pull/9592)
145+
* [`explicit_auto_deref`]: No longer lints, if the initial value is not a reference or reference
146+
receiver
147+
[#9997](https://github.com/rust-lang/rust-clippy/pull/9997)
148+
* [`module_name_repetitions`], [`single_component_path_imports`]: Now handle `#[allow]`
149+
attributes correctly
150+
[#9879](https://github.com/rust-lang/rust-clippy/pull/9879)
151+
* [`bool_to_int_with_if`]: No longer lints `if let` statements
152+
[#9714](https://github.com/rust-lang/rust-clippy/pull/9714)
153+
* [`needless_borrow`]: No longer lints, `if`-`else`-statements that require the borrow
154+
[#9791](https://github.com/rust-lang/rust-clippy/pull/9791)
155+
* [`needless_borrow`]: No longer lints borrows, if moves were illegal
156+
[#9711](https://github.com/rust-lang/rust-clippy/pull/9711)
157+
* [`manual_swap`]: No longer lints in const context
158+
[#9871](https://github.com/rust-lang/rust-clippy/pull/9871)
159+
160+
### Suggestion Fixes/Improvements
161+
162+
* [`missing_safety_doc`], [`missing_errors_doc`], [`missing_panics_doc`]: No longer show the
163+
entire item in the lint emission.
164+
[#9772](https://github.com/rust-lang/rust-clippy/pull/9772)
165+
* [`needless_lifetimes`]: Only suggests `'_` when it's applicable
166+
[#9743](https://github.com/rust-lang/rust-clippy/pull/9743)
167+
* [`use_self`]: Now suggests full paths correctly
168+
[#9726](https://github.com/rust-lang/rust-clippy/pull/9726)
169+
* [`redundant_closure_call`]: Now correctly deals with macros during suggestion creation
170+
[#9987](https://github.com/rust-lang/rust-clippy/pull/9987)
171+
* [`unnecessary_cast`]: Suggestions now correctly deal with references
172+
[#9996](https://github.com/rust-lang/rust-clippy/pull/9996)
173+
* [`unnecessary_join`]: Suggestions now correctly use [turbofish] operators
174+
[#9779](https://github.com/rust-lang/rust-clippy/pull/9779)
175+
* [`equatable_if_let`]: Can now suggest `matches!` replacements
176+
[#9368](https://github.com/rust-lang/rust-clippy/pull/9368)
177+
* [`string_extend_chars`]: Suggestions now correctly work for `str` slices
178+
[#9741](https://github.com/rust-lang/rust-clippy/pull/9741)
179+
* [`redundant_closure_for_method_calls`]: Suggestions now include angle brackets and generic
180+
arguments if needed
181+
[#9745](https://github.com/rust-lang/rust-clippy/pull/9745)
182+
* [`manual_let_else`]: Suggestions no longer expand macro calls
183+
[#9943](https://github.com/rust-lang/rust-clippy/pull/9943)
184+
* [`infallible_destructuring_match`]: Suggestions now preserve references
185+
[#9850](https://github.com/rust-lang/rust-clippy/pull/9850)
186+
* [`result_large_err`]: The error now shows the largest enum variant
187+
[#9662](https://github.com/rust-lang/rust-clippy/pull/9662)
188+
* [`needless_return`]: Suggestions are now formatted better
189+
[#9967](https://github.com/rust-lang/rust-clippy/pull/9967)
190+
* [`unused_rounding`]: The suggestion now preserves the original float literal notation
191+
[#9870](https://github.com/rust-lang/rust-clippy/pull/9870)
192+
193+
[turbofish]: https://turbo.fish/::%3CClippy%3E
194+
195+
### ICE Fixes
196+
197+
* [`result_large_err`]: Fixed ICE for empty enums
198+
[#10007](https://github.com/rust-lang/rust-clippy/pull/10007)
199+
* [`redundant_allocation`]: Fixed ICE for types with bounded variables
200+
[#9773](https://github.com/rust-lang/rust-clippy/pull/9773)
201+
* [`unused_rounding`]: Fixed ICE, if `_` was used as a separator
202+
[#10001](https://github.com/rust-lang/rust-clippy/pull/10001)
10203

11204
## Rust 1.66
12205

13-
Current stable, released 2022-12-15
206+
Released 2022-12-15
14207

15208
[b52fb523...4f142aa1](https://github.com/rust-lang/rust-clippy/compare/b52fb523...4f142aa1)
16209

@@ -166,6 +359,7 @@ Current stable, released 2022-12-15
166359

167360
* [`unnecessary_to_owned`]: Avoid ICEs in favor of false negatives if information is missing
168361
[#9505](https://github.com/rust-lang/rust-clippy/pull/9505)
362+
[#10027](https://github.com/rust-lang/rust-clippy/pull/10027)
169363
* [`manual_range_contains`]: No longer ICEs on values behind references
170364
[#9627](https://github.com/rust-lang/rust-clippy/pull/9627)
171365
* [`needless_pass_by_value`]: No longer ICEs on unsized `dyn Fn` arguments
@@ -4383,6 +4577,7 @@ Released 2018-09-13
43834577
[`multi_assignments`]: https://rust-lang.github.io/rust-clippy/master/index.html#multi_assignments
43844578
[`multiple_crate_versions`]: https://rust-lang.github.io/rust-clippy/master/index.html#multiple_crate_versions
43854579
[`multiple_inherent_impl`]: https://rust-lang.github.io/rust-clippy/master/index.html#multiple_inherent_impl
4580+
[`multiple_unsafe_ops_per_block`]: https://rust-lang.github.io/rust-clippy/master/index.html#multiple_unsafe_ops_per_block
43864581
[`must_use_candidate`]: https://rust-lang.github.io/rust-clippy/master/index.html#must_use_candidate
43874582
[`must_use_unit`]: https://rust-lang.github.io/rust-clippy/master/index.html#must_use_unit
43884583
[`mut_from_ref`]: https://rust-lang.github.io/rust-clippy/master/index.html#mut_from_ref

src/tools/clippy/Cargo.toml

+1-1
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,6 @@
11
[package]
22
name = "clippy"
3-
version = "0.1.68"
3+
version = "0.1.69"
44
description = "A bunch of helpful lints to avoid common pitfalls in Rust"
55
repository = "https://github.com/rust-lang/rust-clippy"
66
readme = "README.md"

src/tools/clippy/README.md

+13-3
Original file line numberDiff line numberDiff line change
@@ -194,11 +194,21 @@ value` mapping e.g.
194194
```toml
195195
avoid-breaking-exported-api = false
196196
disallowed-names = ["toto", "tata", "titi"]
197-
cognitive-complexity-threshold = 30
198197
```
199198

200-
See the [list of configurable lints](https://rust-lang.github.io/rust-clippy/master/index.html#Configuration),
201-
the lint descriptions contain the names and meanings of these configuration variables.
199+
The [table of configurations](https://doc.rust-lang.org/nightly/clippy/lint_configuration.html)
200+
contains all config values, their default, and a list of lints they affect.
201+
Each [configurable lint](https://rust-lang.github.io/rust-clippy/master/index.html#Configuration)
202+
, also contains information about these values.
203+
204+
For configurations that are a list type with default values such as
205+
[disallowed-names](https://rust-lang.github.io/rust-clippy/master/index.html#disallowed_names),
206+
you can use the unique value `".."` to extend the default values instead of replacing them.
207+
208+
```toml
209+
# default of disallowed-names is ["foo", "baz", "quux"]
210+
disallowed-names = ["bar", ".."] # -> ["bar", "foo", "baz", "quux"]
211+
```
202212

203213
> **Note**
204214
>

src/tools/clippy/book/src/SUMMARY.md

+1
Original file line numberDiff line numberDiff line change
@@ -5,6 +5,7 @@
55
- [Installation](installation.md)
66
- [Usage](usage.md)
77
- [Configuration](configuration.md)
8+
- [Lint Configuration](lint_configuration.md)
89
- [Clippy's Lints](lints.md)
910
- [Continuous Integration](continuous_integration/README.md)
1011
- [GitHub Actions](continuous_integration/github_actions.md)

src/tools/clippy/book/src/configuration.md

+13-3
Original file line numberDiff line numberDiff line change
@@ -8,11 +8,21 @@ basic `variable = value` mapping eg.
88
```toml
99
avoid-breaking-exported-api = false
1010
disallowed-names = ["toto", "tata", "titi"]
11-
cognitive-complexity-threshold = 30
1211
```
1312

14-
See the [list of configurable lints](https://rust-lang.github.io/rust-clippy/master/index.html#Configuration),
15-
the lint descriptions contain the names and meanings of these configuration variables.
13+
The [table of configurations](./lint_configuration.md)
14+
contains all config values, their default, and a list of lints they affect.
15+
Each [configurable lint](https://rust-lang.github.io/rust-clippy/master/index.html#Configuration)
16+
, also contains information about these values.
17+
18+
For configurations that are a list type with default values such as
19+
[disallowed-names](https://rust-lang.github.io/rust-clippy/master/index.html#disallowed_names),
20+
you can use the unique value `".."` to extend the default values instead of replacing them.
21+
22+
```toml
23+
# default of disallowed-names is ["foo", "baz", "quux"]
24+
disallowed-names = ["bar", ".."] # -> ["bar", "foo", "baz", "quux"]
25+
```
1626

1727
To deactivate the "for further information visit *lint-link*" message you can define the `CLIPPY_DISABLE_DOCS_LINKS`
1828
environment variable.

src/tools/clippy/book/src/development/adding_lints.md

+6-1
Original file line numberDiff line numberDiff line change
@@ -146,7 +146,8 @@ For cargo lints, the process of testing differs in that we are interested in the
146146
manifest.
147147

148148
If our new lint is named e.g. `foo_categories`, after running `cargo dev
149-
new_lint` we will find by default two new crates, each with its manifest file:
149+
new_lint --name=foo_categories --type=cargo --category=cargo` we will find by
150+
default two new crates, each with its manifest file:
150151

151152
* `tests/ui-cargo/foo_categories/fail/Cargo.toml`: this file should cause the
152153
new lint to raise an error.
@@ -699,6 +700,10 @@ for some users. Adding a configuration is done in the following steps:
699700
`clippy.toml` file with the configuration value and a rust file that
700701
should be linted by Clippy. The test can otherwise be written as usual.
701702

703+
5. Update [Lint Configuration](../lint_configuration.md)
704+
705+
Run `cargo collect-metadata` to generate documentation changes for the book.
706+
702707
[`clippy_lints::utils::conf`]: https://github.com/rust-lang/rust-clippy/blob/master/clippy_lints/src/utils/conf.rs
703708
[`clippy_lints` lib file]: https://github.com/rust-lang/rust-clippy/blob/master/clippy_lints/src/lib.rs
704709
[`tests/ui`]: https://github.com/rust-lang/rust-clippy/blob/master/tests/ui

0 commit comments

Comments
 (0)