Skip to content

Commit 8baeddf

Browse files
committed
Auto merge of #92437 - flip1995:clippyup, r=Manishearth
Update Clippy r? `@Manishearth`
2 parents a09f775 + 4bb6fde commit 8baeddf

File tree

80 files changed

+1493
-439
lines changed

Some content is hidden

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

80 files changed

+1493
-439
lines changed

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

+4
Original file line numberDiff line numberDiff line change
@@ -58,6 +58,10 @@ jobs:
5858
run: cargo test --features deny-warnings,internal-lints,metadata-collector-lint
5959
working-directory: clippy_lints
6060

61+
- name: Test clippy_utils
62+
run: cargo test --features deny-warnings,internal-lints,metadata-collector-lint
63+
working-directory: clippy_utils
64+
6165
- name: Test rustc_tools_util
6266
run: cargo test --features deny-warnings
6367
working-directory: rustc_tools_util

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

+4
Original file line numberDiff line numberDiff line change
@@ -121,6 +121,10 @@ jobs:
121121
run: cargo test --features deny-warnings,internal-lints,metadata-collector-lint
122122
working-directory: clippy_lints
123123

124+
- name: Test clippy_utils
125+
run: cargo test --features deny-warnings,internal-lints,metadata-collector-lint
126+
working-directory: clippy_utils
127+
124128
- name: Test rustc_tools_util
125129
run: cargo test --features deny-warnings
126130
working-directory: rustc_tools_util

src/tools/clippy/CHANGELOG.md

+119-4
Original file line numberDiff line numberDiff line change
@@ -6,13 +6,127 @@ document.
66

77
## Unreleased / In Rust Nightly
88

9-
[b7f3f7f...master](https://github.com/rust-lang/rust-clippy/compare/b7f3f7f...master)
9+
[e181011...master](https://github.com/rust-lang/rust-clippy/compare/e181011...master)
10+
11+
## Rust 1.58 (beta)
12+
13+
Current beta, release 2022-01-13
14+
15+
[00e31fa...e181011](https://github.com/rust-lang/rust-clippy/compare/00e31fa...e181011)
16+
17+
### New lints
18+
19+
* [`transmute_num_to_bytes`]
20+
[#7805](https://github.com/rust-lang/rust-clippy/pull/7805)
21+
* [`match_str_case_mismatch`]
22+
[#7806](https://github.com/rust-lang/rust-clippy/pull/7806)
23+
* [`format_in_format_args`], [`to_string_in_format_args`]
24+
[#7743](https://github.com/rust-lang/rust-clippy/pull/7743)
25+
* [`uninit_vec`]
26+
[#7682](https://github.com/rust-lang/rust-clippy/pull/7682)
27+
* [`fn_to_numeric_cast_any`]
28+
[#7705](https://github.com/rust-lang/rust-clippy/pull/7705)
29+
* [`undocumented_unsafe_blocks`]
30+
[#7748](https://github.com/rust-lang/rust-clippy/pull/7748)
31+
* [`trailing_empty_array`]
32+
[#7838](https://github.com/rust-lang/rust-clippy/pull/7838)
33+
* [`string_slice`]
34+
[#7878](https://github.com/rust-lang/rust-clippy/pull/7878)
35+
36+
### Moves or deprecations of lints
37+
38+
* Move [`non_send_fields_in_send_ty`] to `suspicious`
39+
[#7874](https://github.com/rust-lang/rust-clippy/pull/7874)
40+
* Move [`non_ascii_literal`] to `restriction`
41+
[#7907](https://github.com/rust-lang/rust-clippy/pull/7907)
42+
43+
### Changes that expand what code existing lints cover
44+
45+
* [`question_mark`] now covers `Result`
46+
[#7840](https://github.com/rust-lang/rust-clippy/pull/7840)
47+
* Make [`useless_format`] recognize bare `format!("")`
48+
[#7801](https://github.com/rust-lang/rust-clippy/pull/7801)
49+
* Lint on underscored variables with no side effects in [`no_effect`]
50+
[#7775](https://github.com/rust-lang/rust-clippy/pull/7775)
51+
* Expand [`match_ref_pats`] to check for multiple reference patterns
52+
[#7800](https://github.com/rust-lang/rust-clippy/pull/7800)
53+
54+
### False positive fixes
55+
56+
* Fix false positive of [`implicit_saturating_sub`] with `else` clause
57+
[#7832](https://github.com/rust-lang/rust-clippy/pull/7832)
58+
* Fix [`question_mark`] when there is call in conditional predicate
59+
[#7860](https://github.com/rust-lang/rust-clippy/pull/7860)
60+
* [`mut_mut`] no longer lints when type is defined in external macros
61+
[#7795](https://github.com/rust-lang/rust-clippy/pull/7795)
62+
* Avoid [`eq_op`] in test functions
63+
[#7811](https://github.com/rust-lang/rust-clippy/pull/7811)
64+
* [`cast_possible_truncation`] no longer lints when cast is coming from `signum`
65+
method call [#7850](https://github.com/rust-lang/rust-clippy/pull/7850)
66+
* [`match_str_case_mismatch`] no longer lints on uncased characters
67+
[#7865](https://github.com/rust-lang/rust-clippy/pull/7865)
68+
* [`ptr_arg`] no longer lints references to type aliases
69+
[#7890](https://github.com/rust-lang/rust-clippy/pull/7890)
70+
* [`missing_safety_doc`] now also accepts "implementation safety" headers
71+
[#7856](https://github.com/rust-lang/rust-clippy/pull/7856)
72+
* [`missing_safety_doc`] no longer lints if any parent has `#[doc(hidden)]`
73+
attribute [#7849](https://github.com/rust-lang/rust-clippy/pull/7849)
74+
* [`if_not_else`] now ignores else-if statements
75+
[#7895](https://github.com/rust-lang/rust-clippy/pull/7895)
76+
* Avoid linting [`cast_possible_truncation`] on bit-reducing operations
77+
[#7819](https://github.com/rust-lang/rust-clippy/pull/7819)
78+
* Avoid linting [`field_reassign_with_default`] when `Drop` and `Copy` are
79+
involved [#7794](https://github.com/rust-lang/rust-clippy/pull/7794)
80+
* [`unnecessary_sort_by`] now checks if argument implements `Ord` trait
81+
[#7824](https://github.com/rust-lang/rust-clippy/pull/7824)
82+
* Fix false positive in [`match_overlapping_arm`]
83+
[#7847](https://github.com/rust-lang/rust-clippy/pull/7847)
84+
* Prevent [`needless_lifetimes`] false positive in `async` function definition
85+
[#7901](https://github.com/rust-lang/rust-clippy/pull/7901)
86+
87+
### Suggestion fixes/improvements
88+
89+
* Keep an initial `::` when [`doc_markdown`] suggests to use ticks
90+
[#7916](https://github.com/rust-lang/rust-clippy/pull/7916)
91+
* Add a machine applicable suggestion for the [`doc_markdown`] missing backticks
92+
lint [#7904](https://github.com/rust-lang/rust-clippy/pull/7904)
93+
* [`equatable_if_let`] no longer expands macros in the suggestion
94+
[#7788](https://github.com/rust-lang/rust-clippy/pull/7788)
95+
* Make [`shadow_reuse`] suggestion less verbose
96+
[#7782](https://github.com/rust-lang/rust-clippy/pull/7782)
97+
98+
### ICE fixes
99+
100+
* Fix ICE in [`enum_variant_names`]
101+
[#7873](https://github.com/rust-lang/rust-clippy/pull/7873)
102+
* Fix ICE in [`undocumented_unsafe_blocks`]
103+
[#7891](https://github.com/rust-lang/rust-clippy/pull/7891)
104+
105+
### Documentation improvements
106+
107+
* Fixed naive doc formatting for `#[must_use]` lints ([`must_use_unit`],
108+
[`double_must_use`], [`must_use_candidate`], [`let_underscore_must_use`])
109+
[#7827](https://github.com/rust-lang/rust-clippy/pull/7827)
110+
* Fix typo in example for [`match_result_ok`]
111+
[#7815](https://github.com/rust-lang/rust-clippy/pull/7815)
112+
113+
### Others
114+
115+
* Allow giving reasons for [`disallowed_types`]
116+
[#7791](https://github.com/rust-lang/rust-clippy/pull/7791)
117+
* Fix [`manual_assert`] and [`match_wild_err_arm`] for `#![no_std]` and Rust
118+
2021. [#7851](https://github.com/rust-lang/rust-clippy/pull/7851)
119+
* Fix regression in [`semicolon_if_nothing_returned`] on macros containing while
120+
loops [#7789](https://github.com/rust-lang/rust-clippy/pull/7789)
121+
* Added a new configuration `literal-suffix-style` to enforce a certain style
122+
writing [`unseparated_literal_suffix`]
123+
[#7726](https://github.com/rust-lang/rust-clippy/pull/7726)
10124

11125
## Rust 1.57
12126

13-
Current beta, release 2021-12-02
127+
Current stable, released 2021-12-02
14128

15-
[7bfc26e...b7f3f7f](https://github.com/rust-lang/rust-clippy/compare/7bfc26e...b7f3f7f)
129+
[7bfc26e...00e31fa](https://github.com/rust-lang/rust-clippy/compare/7bfc26e...00e31fa)
16130

17131
### New Lints
18132

@@ -161,7 +275,7 @@ Current beta, release 2021-12-02
161275

162276
## Rust 1.56
163277

164-
Current stable, released 2021-10-21
278+
Released 2021-10-21
165279

166280
[74d1561...7bfc26e](https://github.com/rust-lang/rust-clippy/compare/74d1561...7bfc26e)
167281

@@ -2912,6 +3026,7 @@ Released 2018-09-13
29123026
[`infinite_iter`]: https://rust-lang.github.io/rust-clippy/master/index.html#infinite_iter
29133027
[`inherent_to_string`]: https://rust-lang.github.io/rust-clippy/master/index.html#inherent_to_string
29143028
[`inherent_to_string_shadow_display`]: https://rust-lang.github.io/rust-clippy/master/index.html#inherent_to_string_shadow_display
3029+
[`init_numbered_fields`]: https://rust-lang.github.io/rust-clippy/master/index.html#init_numbered_fields
29153030
[`inline_always`]: https://rust-lang.github.io/rust-clippy/master/index.html#inline_always
29163031
[`inline_asm_x86_att_syntax`]: https://rust-lang.github.io/rust-clippy/master/index.html#inline_asm_x86_att_syntax
29173032
[`inline_asm_x86_intel_syntax`]: https://rust-lang.github.io/rust-clippy/master/index.html#inline_asm_x86_intel_syntax

src/tools/clippy/CONTRIBUTING.md

+4-4
Original file line numberDiff line numberDiff line change
@@ -118,16 +118,16 @@ which `IntelliJ Rust` will be able to understand.
118118
Run `cargo dev setup intellij --repo-path <repo-path>` where `<repo-path>` is a path to the rustc repo
119119
you just cloned.
120120
The command will add path-dependencies pointing towards rustc-crates inside the rustc repo to
121-
Clippys `Cargo.toml`s and should allow `IntelliJ Rust` to understand most of the types that Clippy uses.
121+
Clippy's `Cargo.toml`s and should allow `IntelliJ Rust` to understand most of the types that Clippy uses.
122122
Just make sure to remove the dependencies again before finally making a pull request!
123123

124124
[rustc_repo]: https://github.com/rust-lang/rust/
125125
[IntelliJ_rust_homepage]: https://intellij-rust.github.io/
126126

127127
### Rust Analyzer
128128
As of [#6869][6869], [`rust-analyzer`][ra_homepage] can understand that Clippy uses compiler-internals
129-
using `extern crate` when `package.metadata.rust-analyzer.rustc_private` is set to `true` in Clippys `Cargo.toml.`
130-
You will required a `nightly` toolchain with the `rustc-dev` component installed.
129+
using `extern crate` when `package.metadata.rust-analyzer.rustc_private` is set to `true` in Clippy's `Cargo.toml.`
130+
You will require a `nightly` toolchain with the `rustc-dev` component installed.
131131
Make sure that in the `rust-analyzer` configuration, you set
132132
```
133133
{ "rust-analyzer.rustcSource": "discover" }
@@ -228,7 +228,7 @@ about `subtree`s in the Rust repository see [Rust's `CONTRIBUTING.md`][subtree].
228228

229229
### Patching git-subtree to work with big repos
230230

231-
Currently there's a bug in `git-subtree` that prevents it from working properly
231+
Currently, there's a bug in `git-subtree` that prevents it from working properly
232232
with the [`rust-lang/rust`] repo. There's an open PR to fix that, but it's stale.
233233
Before continuing with the following steps, we need to manually apply that fix to
234234
our local copy of `git-subtree`.

src/tools/clippy/README.md

+7-3
Original file line numberDiff line numberDiff line change
@@ -144,7 +144,7 @@ line. (You can swap `clippy::all` with the specific lint category you are target
144144
## Configuration
145145

146146
Some lints can be configured in a TOML file named `clippy.toml` or `.clippy.toml`. It contains a basic `variable =
147-
value` mapping eg.
147+
value` mapping e.g.
148148

149149
```toml
150150
avoid-breaking-exported-api = false
@@ -155,6 +155,10 @@ cognitive-complexity-threshold = 30
155155
See the [list of lints](https://rust-lang.github.io/rust-clippy/master/index.html) for more information about which
156156
lints can be configured and the meaning of the variables.
157157

158+
Note that configuration changes will not apply for code that has already been compiled and cached under `./target/`;
159+
for example, adding a new string to `doc-valid-idents` may still result in Clippy flagging that string. To be sure that
160+
any configuration changes are applied, you may want to run `cargo clean` and re-compile your crate from scratch.
161+
158162
To deactivate the “for further information visit *lint-link*” message you can
159163
define the `CLIPPY_DISABLE_DOCS_LINKS` environment variable.
160164

@@ -193,7 +197,7 @@ And to warn on `lint_name`, run
193197
cargo clippy -- -W clippy::lint_name
194198
```
195199

196-
This also works with lint groups. For example you
200+
This also works with lint groups. For example, you
197201
can run Clippy with warnings for all lints enabled:
198202
```terminal
199203
cargo clippy -- -W clippy::pedantic
@@ -228,7 +232,7 @@ fn main() {
228232
You can also omit the patch version when specifying the MSRV, so `msrv = 1.30`
229233
is equivalent to `msrv = 1.30.0`.
230234

231-
Note: `custom_inner_attributes` is an unstable feature so it has to be enabled explicitly.
235+
Note: `custom_inner_attributes` is an unstable feature, so it has to be enabled explicitly.
232236

233237
Lints that recognize this configuration option can be found [here](https://rust-lang.github.io/rust-clippy/master/index.html#msrv)
234238

src/tools/clippy/clippy_lints/src/approx_const.rs

+1-1
Original file line numberDiff line numberDiff line change
@@ -87,7 +87,7 @@ impl ApproxConstant {
8787
let s = s.as_str();
8888
if s.parse::<f64>().is_ok() {
8989
for &(constant, name, min_digits, msrv) in &KNOWN_CONSTS {
90-
if is_approx_const(constant, &s, min_digits)
90+
if is_approx_const(constant, s, min_digits)
9191
&& msrv.as_ref().map_or(true, |msrv| meets_msrv(self.msrv.as_ref(), msrv))
9292
{
9393
span_lint_and_help(

src/tools/clippy/clippy_lints/src/attrs.rs

+4-2
Original file line numberDiff line numberDiff line change
@@ -310,8 +310,10 @@ impl<'tcx> LateLintPass<'tcx> for Attributes {
310310
|| is_word(lint, sym::deprecated)
311311
|| is_word(lint, sym!(unreachable_pub))
312312
|| is_word(lint, sym!(unused))
313-
|| extract_clippy_lint(lint).map_or(false, |s| s.as_str() == "wildcard_imports")
314-
|| extract_clippy_lint(lint).map_or(false, |s| s.as_str() == "enum_glob_use")
313+
|| extract_clippy_lint(lint)
314+
.map_or(false, |s| s.as_str() == "wildcard_imports")
315+
|| extract_clippy_lint(lint)
316+
.map_or(false, |s| s.as_str() == "enum_glob_use")
315317
{
316318
return;
317319
}

src/tools/clippy/clippy_lints/src/casts/unnecessary_cast.rs

+3-2
Original file line numberDiff line numberDiff line change
@@ -49,8 +49,9 @@ pub(super) fn check(
4949
if cast_from.kind() == cast_to.kind() =>
5050
{
5151
if let Some(src) = snippet_opt(cx, lit.span) {
52-
let num_lit = NumericLiteral::from_lit_kind(&src, &lit.node).unwrap();
53-
lint_unnecessary_cast(cx, expr, num_lit.integer, cast_from, cast_to);
52+
if let Some(num_lit) = NumericLiteral::from_lit_kind(&src, &lit.node) {
53+
lint_unnecessary_cast(cx, expr, num_lit.integer, cast_from, cast_to);
54+
}
5455
}
5556
},
5657
_ => {

0 commit comments

Comments
 (0)