Skip to content

Commit 0be5779

Browse files
committed
Merge commit '0f7558148c22e53cd4608773b56cdfa50dcdeac3' into clippyup
2 parents 9b8dbd5 + 0f75581 commit 0be5779

File tree

76 files changed

+2192
-560
lines changed

Some content is hidden

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

76 files changed

+2192
-560
lines changed

src/tools/clippy/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

src/tools/clippy/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"

src/tools/clippy/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.

src/tools/clippy/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

src/tools/clippy/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

src/tools/clippy/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"

src/tools/clippy/clippy_dev/src/main.rs

+69-58
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

@@ -11,22 +11,22 @@ fn main() {
1111

1212
match matches.subcommand() {
1313
Some(("bless", matches)) => {
14-
bless::bless(matches.contains_id("ignore-timestamp"));
14+
bless::bless(matches.get_flag("ignore-timestamp"));
1515
},
1616
Some(("dogfood", matches)) => {
1717
dogfood::dogfood(
18-
matches.contains_id("fix"),
19-
matches.contains_id("allow-dirty"),
20-
matches.contains_id("allow-staged"),
18+
matches.get_flag("fix"),
19+
matches.get_flag("allow-dirty"),
20+
matches.get_flag("allow-staged"),
2121
);
2222
},
2323
Some(("fmt", matches)) => {
24-
fmt::run(matches.contains_id("check"), matches.contains_id("verbose"));
24+
fmt::run(matches.get_flag("check"), matches.get_flag("verbose"));
2525
},
2626
Some(("update_lints", matches)) => {
27-
if matches.contains_id("print-only") {
27+
if matches.get_flag("print-only") {
2828
update_lints::print_lints();
29-
} else if matches.contains_id("check") {
29+
} else if matches.get_flag("check") {
3030
update_lints::update(update_lints::UpdateMode::Check);
3131
} else {
3232
update_lints::update(update_lints::UpdateMode::Change);
@@ -38,15 +38,15 @@ fn main() {
3838
matches.get_one::<String>("name"),
3939
matches.get_one::<String>("category").map(String::as_str),
4040
matches.get_one::<String>("type").map(String::as_str),
41-
matches.contains_id("msrv"),
41+
matches.get_flag("msrv"),
4242
) {
4343
Ok(_) => update_lints::update(update_lints::UpdateMode::Change),
4444
Err(e) => eprintln!("Unable to create lint: {e}"),
4545
}
4646
},
4747
Some(("setup", sub_command)) => match sub_command.subcommand() {
4848
Some(("intellij", matches)) => {
49-
if matches.contains_id("remove") {
49+
if matches.get_flag("remove") {
5050
setup::intellij::remove_rustc_src();
5151
} else {
5252
setup::intellij::setup_rustc_src(
@@ -57,17 +57,17 @@ fn main() {
5757
}
5858
},
5959
Some(("git-hook", matches)) => {
60-
if matches.contains_id("remove") {
60+
if matches.get_flag("remove") {
6161
setup::git_hook::remove_hook();
6262
} else {
63-
setup::git_hook::install_hook(matches.contains_id("force-override"));
63+
setup::git_hook::install_hook(matches.get_flag("force-override"));
6464
}
6565
},
6666
Some(("vscode-tasks", matches)) => {
67-
if matches.contains_id("remove") {
67+
if matches.get_flag("remove") {
6868
setup::vscode::remove_tasks();
6969
} else {
70-
setup::vscode::install_tasks(matches.contains_id("force-override"));
70+
setup::vscode::install_tasks(matches.get_flag("force-override"));
7171
}
7272
},
7373
_ => {},
@@ -91,7 +91,7 @@ fn main() {
9191
Some(("rename_lint", matches)) => {
9292
let old_name = matches.get_one::<String>("old_name").unwrap();
9393
let new_name = matches.get_one::<String>("new_name").unwrap_or(old_name);
94-
let uplift = matches.contains_id("uplift");
94+
let uplift = matches.get_flag("uplift");
9595
update_lints::rename(old_name, new_name, uplift);
9696
},
9797
Some(("deprecate", matches)) => {
@@ -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
])

0 commit comments

Comments
 (0)