Skip to content

Commit 7c61b4e

Browse files
committed
Merge remote-tracking branch 'upstream/master' into rustup
2 parents 821199c + 5adeebf commit 7c61b4e

File tree

86 files changed

+2218
-589
lines changed

Some content is hidden

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

86 files changed

+2218
-589
lines changed

CHANGELOG.md

+1
Original file line numberDiff line numberDiff line change
@@ -4383,6 +4383,7 @@ Released 2018-09-13
43834383
[`extend_from_slice`]: https://rust-lang.github.io/rust-clippy/master/index.html#extend_from_slice
43844384
[`extend_with_drain`]: https://rust-lang.github.io/rust-clippy/master/index.html#extend_with_drain
43854385
[`extra_unused_lifetimes`]: https://rust-lang.github.io/rust-clippy/master/index.html#extra_unused_lifetimes
4386+
[`extra_unused_type_parameters`]: https://rust-lang.github.io/rust-clippy/master/index.html#extra_unused_type_parameters
43864387
[`fallible_impl_from`]: https://rust-lang.github.io/rust-clippy/master/index.html#fallible_impl_from
43874388
[`field_reassign_with_default`]: https://rust-lang.github.io/rust-clippy/master/index.html#field_reassign_with_default
43884389
[`filetype_is_file`]: https://rust-lang.github.io/rust-clippy/master/index.html#filetype_is_file

Cargo.toml

+1
Original file line numberDiff line numberDiff line change
@@ -42,6 +42,7 @@ filetime = "0.2"
4242
rustc-workspace-hack = "1.0"
4343

4444
# UI test dependencies
45+
clap = { version = "4.1.4", features = ["derive"] }
4546
clippy_utils = { path = "clippy_utils" }
4647
derive-new = "0.5"
4748
if_chain = "1.0"

README.md

+1-1
Original file line numberDiff line numberDiff line change
@@ -5,7 +5,7 @@
55

66
A collection of lints to catch common mistakes and improve your [Rust](https://github.com/rust-lang/rust) code.
77

8-
[There are over 550 lints included in this crate!](https://rust-lang.github.io/rust-clippy/master/index.html)
8+
[There are over 600 lints included in this crate!](https://rust-lang.github.io/rust-clippy/master/index.html)
99

1010
Lints are divided into categories, each with a default [lint level](https://doc.rust-lang.org/rustc/lints/levels.html).
1111
You can choose how much Clippy is supposed to ~~annoy~~ help you by changing the lint level by category.

book/src/README.md

+1-1
Original file line numberDiff line numberDiff line change
@@ -6,7 +6,7 @@
66
A collection of lints to catch common mistakes and improve your
77
[Rust](https://github.com/rust-lang/rust) code.
88

9-
[There are over 550 lints included in this crate!](https://rust-lang.github.io/rust-clippy/master/index.html)
9+
[There are over 600 lints included in this crate!](https://rust-lang.github.io/rust-clippy/master/index.html)
1010

1111
Lints are divided into categories, each with a default [lint
1212
level](https://doc.rust-lang.org/rustc/lints/levels.html). You can choose how

book/src/lint_configuration.md

+23-3
Original file line numberDiff line numberDiff line change
@@ -43,6 +43,7 @@ Please use that command to update the file and do not edit it by hand.
4343
| [allowed-scripts](#allowed-scripts) | `["Latin"]` |
4444
| [enable-raw-pointer-heuristic-for-send](#enable-raw-pointer-heuristic-for-send) | `true` |
4545
| [max-suggested-slice-pattern-length](#max-suggested-slice-pattern-length) | `3` |
46+
| [await-holding-invalid-types](#await-holding-invalid-types) | `[]` |
4647
| [max-include-file-size](#max-include-file-size) | `1000000` |
4748
| [allow-expect-in-tests](#allow-expect-in-tests) | `false` |
4849
| [allow-unwrap-in-tests](#allow-unwrap-in-tests) | `false` |
@@ -167,6 +168,17 @@ The minimum rust version that the project supports
167168
* [manual_clamp](https://rust-lang.github.io/rust-clippy/master/index.html#manual_clamp)
168169
* [manual_let_else](https://rust-lang.github.io/rust-clippy/master/index.html#manual_let_else)
169170
* [unchecked_duration_subtraction](https://rust-lang.github.io/rust-clippy/master/index.html#unchecked_duration_subtraction)
171+
* [collapsible_str_replace](https://rust-lang.github.io/rust-clippy/master/index.html#collapsible_str_replace)
172+
* [seek_from_current](https://rust-lang.github.io/rust-clippy/master/index.html#seek_from_current)
173+
* [seek_rewind](https://rust-lang.github.io/rust-clippy/master/index.html#seek_rewind)
174+
* [unnecessary_lazy_evaluations](https://rust-lang.github.io/rust-clippy/master/index.html#unnecessary_lazy_evaluations)
175+
* [transmute_ptr_to_ref](https://rust-lang.github.io/rust-clippy/master/index.html#transmute_ptr_to_ref)
176+
* [almost_complete_range](https://rust-lang.github.io/rust-clippy/master/index.html#almost_complete_range)
177+
* [needless_borrow](https://rust-lang.github.io/rust-clippy/master/index.html#needless_borrow)
178+
* [derivable_impls](https://rust-lang.github.io/rust-clippy/master/index.html#derivable_impls)
179+
* [manual_is_ascii_check](https://rust-lang.github.io/rust-clippy/master/index.html#manual_is_ascii_check)
180+
* [manual_rem_euclid](https://rust-lang.github.io/rust-clippy/master/index.html#manual_rem_euclid)
181+
* [manual_retain](https://rust-lang.github.io/rust-clippy/master/index.html#manual_retain)
170182

171183

172184
### cognitive-complexity-threshold
@@ -279,7 +291,7 @@ The minimum size (in bytes) to consider a type for passing by reference instead
279291

280292
**Default Value:** `256` (`u64`)
281293

282-
* [large_type_pass_by_move](https://rust-lang.github.io/rust-clippy/master/index.html#large_type_pass_by_move)
294+
* [large_types_passed_by_value](https://rust-lang.github.io/rust-clippy/master/index.html#large_types_passed_by_value)
283295

284296

285297
### too-many-lines-threshold
@@ -442,6 +454,14 @@ For example, `[_, _, _, e, ..]` is a slice pattern with 4 elements.
442454
* [index_refutable_slice](https://rust-lang.github.io/rust-clippy/master/index.html#index_refutable_slice)
443455

444456

457+
### await-holding-invalid-types
458+
459+
460+
**Default Value:** `[]` (`Vec<crate::utils::conf::DisallowedPath>`)
461+
462+
* [await_holding_invalid_type](https://rust-lang.github.io/rust-clippy/master/index.html#await_holding_invalid_type)
463+
464+
445465
### max-include-file-size
446466
The maximum size of a file included via `include_bytes!()` or `include_str!()`, in bytes
447467

@@ -497,7 +517,7 @@ for the generic parameters for determining interior mutability
497517

498518
**Default Value:** `["bytes::Bytes"]` (`Vec<String>`)
499519

500-
* [mutable_key](https://rust-lang.github.io/rust-clippy/master/index.html#mutable_key)
520+
* [mutable_key_type](https://rust-lang.github.io/rust-clippy/master/index.html#mutable_key_type)
501521

502522

503523
### allow-mixed-uninlined-format-args
@@ -509,7 +529,7 @@ Whether to allow mixed uninlined format args, e.g. `format!("{} {}", a, foo.bar)
509529

510530

511531
### suppress-restriction-lint-in-const
512-
In same
532+
Whether to suppress a restriction lint in constant code. In same
513533
cases the restructured operation might not be unavoidable, as the
514534
suggested counterparts are unavailable in constant code. This
515535
configuration will cause restriction lints to trigger even

clippy_dev/Cargo.toml

+1-1
Original file line numberDiff line numberDiff line change
@@ -5,7 +5,7 @@ edition = "2021"
55

66
[dependencies]
77
aho-corasick = "0.7"
8-
clap = "3.2"
8+
clap = "4.1.4"
99
indoc = "1.0"
1010
itertools = "0.10.1"
1111
opener = "0.5"

clippy_dev/src/main.rs

+55-44
Original file line numberDiff line numberDiff line change
@@ -2,7 +2,7 @@
22
// warn on lints, that are included in `rust-lang/rust`s bootstrap
33
#![warn(rust_2018_idioms, unused_lifetimes)]
44

5-
use clap::{Arg, ArgAction, ArgMatches, Command, PossibleValue};
5+
use clap::{Arg, ArgAction, ArgMatches, Command};
66
use clippy_dev::{bless, dogfood, fmt, lint, new_lint, serve, setup, update_lints};
77
use indoc::indoc;
88

@@ -110,24 +110,37 @@ fn get_clap_config() -> ArgMatches {
110110
Command::new("bless").about("bless the test output changes").arg(
111111
Arg::new("ignore-timestamp")
112112
.long("ignore-timestamp")
113+
.action(ArgAction::SetTrue)
113114
.help("Include files updated before clippy was built"),
114115
),
115116
Command::new("dogfood").about("Runs the dogfood test").args([
116-
Arg::new("fix").long("fix").help("Apply the suggestions when possible"),
117+
Arg::new("fix")
118+
.long("fix")
119+
.action(ArgAction::SetTrue)
120+
.help("Apply the suggestions when possible"),
117121
Arg::new("allow-dirty")
118122
.long("allow-dirty")
123+
.action(ArgAction::SetTrue)
119124
.help("Fix code even if the working directory has changes")
120125
.requires("fix"),
121126
Arg::new("allow-staged")
122127
.long("allow-staged")
128+
.action(ArgAction::SetTrue)
123129
.help("Fix code even if the working directory has staged changes")
124130
.requires("fix"),
125131
]),
126132
Command::new("fmt")
127133
.about("Run rustfmt on all projects and tests")
128134
.args([
129-
Arg::new("check").long("check").help("Use the rustfmt --check option"),
130-
Arg::new("verbose").short('v').long("verbose").help("Echo commands run"),
135+
Arg::new("check")
136+
.long("check")
137+
.action(ArgAction::SetTrue)
138+
.help("Use the rustfmt --check option"),
139+
Arg::new("verbose")
140+
.short('v')
141+
.long("verbose")
142+
.action(ArgAction::SetTrue)
143+
.help("Echo commands run"),
131144
]),
132145
Command::new("update_lints")
133146
.about("Updates lint registration and information from the source code")
@@ -140,13 +153,17 @@ fn get_clap_config() -> ArgMatches {
140153
* all lints are registered in the lint store",
141154
)
142155
.args([
143-
Arg::new("print-only").long("print-only").help(
144-
"Print a table of lints to STDOUT. \
145-
This does not include deprecated and internal lints. \
146-
(Does not modify any files)",
147-
),
156+
Arg::new("print-only")
157+
.long("print-only")
158+
.action(ArgAction::SetTrue)
159+
.help(
160+
"Print a table of lints to STDOUT. \
161+
This does not include deprecated and internal lints. \
162+
(Does not modify any files)",
163+
),
148164
Arg::new("check")
149165
.long("check")
166+
.action(ArgAction::SetTrue)
150167
.help("Checks that `cargo dev update_lints` has been run. Used on CI."),
151168
]),
152169
Command::new("new_lint")
@@ -156,41 +173,37 @@ fn get_clap_config() -> ArgMatches {
156173
.short('p')
157174
.long("pass")
158175
.help("Specify whether the lint runs during the early or late pass")
159-
.takes_value(true)
160-
.value_parser([PossibleValue::new("early"), PossibleValue::new("late")])
176+
.value_parser(["early", "late"])
161177
.conflicts_with("type")
162178
.required_unless_present("type"),
163179
Arg::new("name")
164180
.short('n')
165181
.long("name")
166182
.help("Name of the new lint in snake case, ex: fn_too_long")
167-
.takes_value(true)
168183
.required(true),
169184
Arg::new("category")
170185
.short('c')
171186
.long("category")
172187
.help("What category the lint belongs to")
173188
.default_value("nursery")
174189
.value_parser([
175-
PossibleValue::new("style"),
176-
PossibleValue::new("correctness"),
177-
PossibleValue::new("suspicious"),
178-
PossibleValue::new("complexity"),
179-
PossibleValue::new("perf"),
180-
PossibleValue::new("pedantic"),
181-
PossibleValue::new("restriction"),
182-
PossibleValue::new("cargo"),
183-
PossibleValue::new("nursery"),
184-
PossibleValue::new("internal"),
185-
PossibleValue::new("internal_warn"),
186-
])
187-
.takes_value(true),
188-
Arg::new("type")
189-
.long("type")
190-
.help("What directory the lint belongs in")
191-
.takes_value(true)
192-
.required(false),
193-
Arg::new("msrv").long("msrv").help("Add MSRV config code to the lint"),
190+
"style",
191+
"correctness",
192+
"suspicious",
193+
"complexity",
194+
"perf",
195+
"pedantic",
196+
"restriction",
197+
"cargo",
198+
"nursery",
199+
"internal",
200+
"internal_warn",
201+
]),
202+
Arg::new("type").long("type").help("What directory the lint belongs in"),
203+
Arg::new("msrv")
204+
.long("msrv")
205+
.action(ArgAction::SetTrue)
206+
.help("Add MSRV config code to the lint"),
194207
]),
195208
Command::new("setup")
196209
.about("Support for setting up your personal development environment")
@@ -201,13 +214,12 @@ fn get_clap_config() -> ArgMatches {
201214
.args([
202215
Arg::new("remove")
203216
.long("remove")
204-
.help("Remove the dependencies added with 'cargo dev setup intellij'")
205-
.required(false),
217+
.action(ArgAction::SetTrue)
218+
.help("Remove the dependencies added with 'cargo dev setup intellij'"),
206219
Arg::new("rustc-repo-path")
207220
.long("repo-path")
208221
.short('r')
209222
.help("The path to a rustc repo that will be used for setting the dependencies")
210-
.takes_value(true)
211223
.value_name("path")
212224
.conflicts_with("remove")
213225
.required(true),
@@ -217,26 +229,26 @@ fn get_clap_config() -> ArgMatches {
217229
.args([
218230
Arg::new("remove")
219231
.long("remove")
220-
.help("Remove the pre-commit hook added with 'cargo dev setup git-hook'")
221-
.required(false),
232+
.action(ArgAction::SetTrue)
233+
.help("Remove the pre-commit hook added with 'cargo dev setup git-hook'"),
222234
Arg::new("force-override")
223235
.long("force-override")
224236
.short('f')
225-
.help("Forces the override of an existing git pre-commit hook")
226-
.required(false),
237+
.action(ArgAction::SetTrue)
238+
.help("Forces the override of an existing git pre-commit hook"),
227239
]),
228240
Command::new("vscode-tasks")
229241
.about("Add several tasks to vscode for formatting, validation and testing")
230242
.args([
231243
Arg::new("remove")
232244
.long("remove")
233-
.help("Remove the tasks added with 'cargo dev setup vscode-tasks'")
234-
.required(false),
245+
.action(ArgAction::SetTrue)
246+
.help("Remove the tasks added with 'cargo dev setup vscode-tasks'"),
235247
Arg::new("force-override")
236248
.long("force-override")
237249
.short('f')
238-
.help("Forces the override of existing vscode tasks")
239-
.required(false),
250+
.action(ArgAction::SetTrue)
251+
.help("Forces the override of existing vscode tasks"),
240252
]),
241253
]),
242254
Command::new("remove")
@@ -295,6 +307,7 @@ fn get_clap_config() -> ArgMatches {
295307
.help("The new name of the lint"),
296308
Arg::new("uplift")
297309
.long("uplift")
310+
.action(ArgAction::SetTrue)
298311
.help("This lint will be uplifted into rustc"),
299312
]),
300313
Command::new("deprecate").about("Deprecates the given lint").args([
@@ -305,8 +318,6 @@ fn get_clap_config() -> ArgMatches {
305318
Arg::new("reason")
306319
.long("reason")
307320
.short('r')
308-
.required(false)
309-
.takes_value(true)
310321
.help("The reason for deprecation"),
311322
]),
312323
])

clippy_lints/Cargo.toml

+2-2
Original file line numberDiff line numberDiff line change
@@ -9,7 +9,7 @@ keywords = ["clippy", "lint", "plugin"]
99
edition = "2021"
1010

1111
[dependencies]
12-
cargo_metadata = "0.14"
12+
cargo_metadata = "0.15.3"
1313
clippy_utils = { path = "../clippy_utils" }
1414
declare_clippy_lint = { path = "../declare_clippy_lint" }
1515
if_chain = "1.0"
@@ -19,7 +19,7 @@ quine-mc_cluskey = "0.2"
1919
regex-syntax = "0.6"
2020
serde = { version = "1.0", features = ["derive"] }
2121
serde_json = { version = "1.0", optional = true }
22-
tempfile = { version = "3.2", optional = true }
22+
tempfile = { version = "3.3.0", optional = true }
2323
toml = "0.5"
2424
unicode-normalization = "0.1"
2525
unicode-script = { version = "0.5", default-features = false }

clippy_lints/src/blocks_in_if_conditions.rs

+1-2
Original file line numberDiff line numberDiff line change
@@ -85,8 +85,7 @@ impl<'tcx> LateLintPass<'tcx> for BlocksInIfConditions {
8585
);
8686
}
8787
} else {
88-
let span =
89-
block.expr.as_ref().map_or_else(|| block.stmts[0].span, |e| e.span);
88+
let span = block.expr.as_ref().map_or_else(|| block.stmts[0].span, |e| e.span);
9089
if span.from_expansion() || expr.span.from_expansion() {
9190
return;
9291
}

0 commit comments

Comments
 (0)