Skip to content

Commit

Permalink
Merge commit '0f7558148c22e53cd4608773b56cdfa50dcdeac3' into clippyup
Browse files Browse the repository at this point in the history
  • Loading branch information
flip1995 committed Feb 10, 2023
1 parent 821199c commit e7fe1f9
Show file tree
Hide file tree
Showing 76 changed files with 2,192 additions and 560 deletions.
1 change: 1 addition & 0 deletions CHANGELOG.md
Original file line number Diff line number Diff line change
Expand Up @@ -4383,6 +4383,7 @@ Released 2018-09-13
[`extend_from_slice`]: https://rust-lang.github.io/rust-clippy/master/index.html#extend_from_slice
[`extend_with_drain`]: https://rust-lang.github.io/rust-clippy/master/index.html#extend_with_drain
[`extra_unused_lifetimes`]: https://rust-lang.github.io/rust-clippy/master/index.html#extra_unused_lifetimes
[`extra_unused_type_parameters`]: https://rust-lang.github.io/rust-clippy/master/index.html#extra_unused_type_parameters
[`fallible_impl_from`]: https://rust-lang.github.io/rust-clippy/master/index.html#fallible_impl_from
[`field_reassign_with_default`]: https://rust-lang.github.io/rust-clippy/master/index.html#field_reassign_with_default
[`filetype_is_file`]: https://rust-lang.github.io/rust-clippy/master/index.html#filetype_is_file
Expand Down
1 change: 1 addition & 0 deletions Cargo.toml
Original file line number Diff line number Diff line change
Expand Up @@ -42,6 +42,7 @@ filetime = "0.2"
rustc-workspace-hack = "1.0"

# UI test dependencies
clap = { version = "4.1.4", features = ["derive"] }
clippy_utils = { path = "clippy_utils" }
derive-new = "0.5"
if_chain = "1.0"
Expand Down
2 changes: 1 addition & 1 deletion README.md
Original file line number Diff line number Diff line change
Expand Up @@ -5,7 +5,7 @@

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

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

Lints are divided into categories, each with a default [lint level](https://doc.rust-lang.org/rustc/lints/levels.html).
You can choose how much Clippy is supposed to ~~annoy~~ help you by changing the lint level by category.
Expand Down
2 changes: 1 addition & 1 deletion book/src/README.md
Original file line number Diff line number Diff line change
Expand Up @@ -6,7 +6,7 @@
A collection of lints to catch common mistakes and improve your
[Rust](https://github.com/rust-lang/rust) code.

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

Lints are divided into categories, each with a default [lint
level](https://doc.rust-lang.org/rustc/lints/levels.html). You can choose how
Expand Down
26 changes: 23 additions & 3 deletions book/src/lint_configuration.md
Original file line number Diff line number Diff line change
Expand Up @@ -43,6 +43,7 @@ Please use that command to update the file and do not edit it by hand.
| [allowed-scripts](#allowed-scripts) | `["Latin"]` |
| [enable-raw-pointer-heuristic-for-send](#enable-raw-pointer-heuristic-for-send) | `true` |
| [max-suggested-slice-pattern-length](#max-suggested-slice-pattern-length) | `3` |
| [await-holding-invalid-types](#await-holding-invalid-types) | `[]` |
| [max-include-file-size](#max-include-file-size) | `1000000` |
| [allow-expect-in-tests](#allow-expect-in-tests) | `false` |
| [allow-unwrap-in-tests](#allow-unwrap-in-tests) | `false` |
Expand Down Expand Up @@ -167,6 +168,17 @@ The minimum rust version that the project supports
* [manual_clamp](https://rust-lang.github.io/rust-clippy/master/index.html#manual_clamp)
* [manual_let_else](https://rust-lang.github.io/rust-clippy/master/index.html#manual_let_else)
* [unchecked_duration_subtraction](https://rust-lang.github.io/rust-clippy/master/index.html#unchecked_duration_subtraction)
* [collapsible_str_replace](https://rust-lang.github.io/rust-clippy/master/index.html#collapsible_str_replace)
* [seek_from_current](https://rust-lang.github.io/rust-clippy/master/index.html#seek_from_current)
* [seek_rewind](https://rust-lang.github.io/rust-clippy/master/index.html#seek_rewind)
* [unnecessary_lazy_evaluations](https://rust-lang.github.io/rust-clippy/master/index.html#unnecessary_lazy_evaluations)
* [transmute_ptr_to_ref](https://rust-lang.github.io/rust-clippy/master/index.html#transmute_ptr_to_ref)
* [almost_complete_range](https://rust-lang.github.io/rust-clippy/master/index.html#almost_complete_range)
* [needless_borrow](https://rust-lang.github.io/rust-clippy/master/index.html#needless_borrow)
* [derivable_impls](https://rust-lang.github.io/rust-clippy/master/index.html#derivable_impls)
* [manual_is_ascii_check](https://rust-lang.github.io/rust-clippy/master/index.html#manual_is_ascii_check)
* [manual_rem_euclid](https://rust-lang.github.io/rust-clippy/master/index.html#manual_rem_euclid)
* [manual_retain](https://rust-lang.github.io/rust-clippy/master/index.html#manual_retain)


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

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

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


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


### await-holding-invalid-types


**Default Value:** `[]` (`Vec<crate::utils::conf::DisallowedPath>`)

* [await_holding_invalid_type](https://rust-lang.github.io/rust-clippy/master/index.html#await_holding_invalid_type)


### max-include-file-size
The maximum size of a file included via `include_bytes!()` or `include_str!()`, in bytes

Expand Down Expand Up @@ -497,7 +517,7 @@ for the generic parameters for determining interior mutability

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

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


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


### suppress-restriction-lint-in-const
In same
Whether to suppress a restriction lint in constant code. In same
cases the restructured operation might not be unavoidable, as the
suggested counterparts are unavailable in constant code. This
configuration will cause restriction lints to trigger even
Expand Down
2 changes: 1 addition & 1 deletion clippy_dev/Cargo.toml
Original file line number Diff line number Diff line change
Expand Up @@ -5,7 +5,7 @@ edition = "2021"

[dependencies]
aho-corasick = "0.7"
clap = "3.2"
clap = "4.1.4"
indoc = "1.0"
itertools = "0.10.1"
opener = "0.5"
Expand Down
127 changes: 69 additions & 58 deletions clippy_dev/src/main.rs
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,7 @@
// warn on lints, that are included in `rust-lang/rust`s bootstrap
#![warn(rust_2018_idioms, unused_lifetimes)]

use clap::{Arg, ArgAction, ArgMatches, Command, PossibleValue};
use clap::{Arg, ArgAction, ArgMatches, Command};
use clippy_dev::{bless, dogfood, fmt, lint, new_lint, serve, setup, update_lints};
use indoc::indoc;

Expand All @@ -11,22 +11,22 @@ fn main() {

match matches.subcommand() {
Some(("bless", matches)) => {
bless::bless(matches.contains_id("ignore-timestamp"));
bless::bless(matches.get_flag("ignore-timestamp"));
},
Some(("dogfood", matches)) => {
dogfood::dogfood(
matches.contains_id("fix"),
matches.contains_id("allow-dirty"),
matches.contains_id("allow-staged"),
matches.get_flag("fix"),
matches.get_flag("allow-dirty"),
matches.get_flag("allow-staged"),
);
},
Some(("fmt", matches)) => {
fmt::run(matches.contains_id("check"), matches.contains_id("verbose"));
fmt::run(matches.get_flag("check"), matches.get_flag("verbose"));
},
Some(("update_lints", matches)) => {
if matches.contains_id("print-only") {
if matches.get_flag("print-only") {
update_lints::print_lints();
} else if matches.contains_id("check") {
} else if matches.get_flag("check") {
update_lints::update(update_lints::UpdateMode::Check);
} else {
update_lints::update(update_lints::UpdateMode::Change);
Expand All @@ -38,15 +38,15 @@ fn main() {
matches.get_one::<String>("name"),
matches.get_one::<String>("category").map(String::as_str),
matches.get_one::<String>("type").map(String::as_str),
matches.contains_id("msrv"),
matches.get_flag("msrv"),
) {
Ok(_) => update_lints::update(update_lints::UpdateMode::Change),
Err(e) => eprintln!("Unable to create lint: {e}"),
}
},
Some(("setup", sub_command)) => match sub_command.subcommand() {
Some(("intellij", matches)) => {
if matches.contains_id("remove") {
if matches.get_flag("remove") {
setup::intellij::remove_rustc_src();
} else {
setup::intellij::setup_rustc_src(
Expand All @@ -57,17 +57,17 @@ fn main() {
}
},
Some(("git-hook", matches)) => {
if matches.contains_id("remove") {
if matches.get_flag("remove") {
setup::git_hook::remove_hook();
} else {
setup::git_hook::install_hook(matches.contains_id("force-override"));
setup::git_hook::install_hook(matches.get_flag("force-override"));
}
},
Some(("vscode-tasks", matches)) => {
if matches.contains_id("remove") {
if matches.get_flag("remove") {
setup::vscode::remove_tasks();
} else {
setup::vscode::install_tasks(matches.contains_id("force-override"));
setup::vscode::install_tasks(matches.get_flag("force-override"));
}
},
_ => {},
Expand All @@ -91,7 +91,7 @@ fn main() {
Some(("rename_lint", matches)) => {
let old_name = matches.get_one::<String>("old_name").unwrap();
let new_name = matches.get_one::<String>("new_name").unwrap_or(old_name);
let uplift = matches.contains_id("uplift");
let uplift = matches.get_flag("uplift");
update_lints::rename(old_name, new_name, uplift);
},
Some(("deprecate", matches)) => {
Expand All @@ -110,24 +110,37 @@ fn get_clap_config() -> ArgMatches {
Command::new("bless").about("bless the test output changes").arg(
Arg::new("ignore-timestamp")
.long("ignore-timestamp")
.action(ArgAction::SetTrue)
.help("Include files updated before clippy was built"),
),
Command::new("dogfood").about("Runs the dogfood test").args([
Arg::new("fix").long("fix").help("Apply the suggestions when possible"),
Arg::new("fix")
.long("fix")
.action(ArgAction::SetTrue)
.help("Apply the suggestions when possible"),
Arg::new("allow-dirty")
.long("allow-dirty")
.action(ArgAction::SetTrue)
.help("Fix code even if the working directory has changes")
.requires("fix"),
Arg::new("allow-staged")
.long("allow-staged")
.action(ArgAction::SetTrue)
.help("Fix code even if the working directory has staged changes")
.requires("fix"),
]),
Command::new("fmt")
.about("Run rustfmt on all projects and tests")
.args([
Arg::new("check").long("check").help("Use the rustfmt --check option"),
Arg::new("verbose").short('v').long("verbose").help("Echo commands run"),
Arg::new("check")
.long("check")
.action(ArgAction::SetTrue)
.help("Use the rustfmt --check option"),
Arg::new("verbose")
.short('v')
.long("verbose")
.action(ArgAction::SetTrue)
.help("Echo commands run"),
]),
Command::new("update_lints")
.about("Updates lint registration and information from the source code")
Expand All @@ -140,13 +153,17 @@ fn get_clap_config() -> ArgMatches {
* all lints are registered in the lint store",
)
.args([
Arg::new("print-only").long("print-only").help(
"Print a table of lints to STDOUT. \
This does not include deprecated and internal lints. \
(Does not modify any files)",
),
Arg::new("print-only")
.long("print-only")
.action(ArgAction::SetTrue)
.help(
"Print a table of lints to STDOUT. \
This does not include deprecated and internal lints. \
(Does not modify any files)",
),
Arg::new("check")
.long("check")
.action(ArgAction::SetTrue)
.help("Checks that `cargo dev update_lints` has been run. Used on CI."),
]),
Command::new("new_lint")
Expand All @@ -156,41 +173,37 @@ fn get_clap_config() -> ArgMatches {
.short('p')
.long("pass")
.help("Specify whether the lint runs during the early or late pass")
.takes_value(true)
.value_parser([PossibleValue::new("early"), PossibleValue::new("late")])
.value_parser(["early", "late"])
.conflicts_with("type")
.required_unless_present("type"),
Arg::new("name")
.short('n')
.long("name")
.help("Name of the new lint in snake case, ex: fn_too_long")
.takes_value(true)
.required(true),
Arg::new("category")
.short('c')
.long("category")
.help("What category the lint belongs to")
.default_value("nursery")
.value_parser([
PossibleValue::new("style"),
PossibleValue::new("correctness"),
PossibleValue::new("suspicious"),
PossibleValue::new("complexity"),
PossibleValue::new("perf"),
PossibleValue::new("pedantic"),
PossibleValue::new("restriction"),
PossibleValue::new("cargo"),
PossibleValue::new("nursery"),
PossibleValue::new("internal"),
PossibleValue::new("internal_warn"),
])
.takes_value(true),
Arg::new("type")
.long("type")
.help("What directory the lint belongs in")
.takes_value(true)
.required(false),
Arg::new("msrv").long("msrv").help("Add MSRV config code to the lint"),
"style",
"correctness",
"suspicious",
"complexity",
"perf",
"pedantic",
"restriction",
"cargo",
"nursery",
"internal",
"internal_warn",
]),
Arg::new("type").long("type").help("What directory the lint belongs in"),
Arg::new("msrv")
.long("msrv")
.action(ArgAction::SetTrue)
.help("Add MSRV config code to the lint"),
]),
Command::new("setup")
.about("Support for setting up your personal development environment")
Expand All @@ -201,13 +214,12 @@ fn get_clap_config() -> ArgMatches {
.args([
Arg::new("remove")
.long("remove")
.help("Remove the dependencies added with 'cargo dev setup intellij'")
.required(false),
.action(ArgAction::SetTrue)
.help("Remove the dependencies added with 'cargo dev setup intellij'"),
Arg::new("rustc-repo-path")
.long("repo-path")
.short('r')
.help("The path to a rustc repo that will be used for setting the dependencies")
.takes_value(true)
.value_name("path")
.conflicts_with("remove")
.required(true),
Expand All @@ -217,26 +229,26 @@ fn get_clap_config() -> ArgMatches {
.args([
Arg::new("remove")
.long("remove")
.help("Remove the pre-commit hook added with 'cargo dev setup git-hook'")
.required(false),
.action(ArgAction::SetTrue)
.help("Remove the pre-commit hook added with 'cargo dev setup git-hook'"),
Arg::new("force-override")
.long("force-override")
.short('f')
.help("Forces the override of an existing git pre-commit hook")
.required(false),
.action(ArgAction::SetTrue)
.help("Forces the override of an existing git pre-commit hook"),
]),
Command::new("vscode-tasks")
.about("Add several tasks to vscode for formatting, validation and testing")
.args([
Arg::new("remove")
.long("remove")
.help("Remove the tasks added with 'cargo dev setup vscode-tasks'")
.required(false),
.action(ArgAction::SetTrue)
.help("Remove the tasks added with 'cargo dev setup vscode-tasks'"),
Arg::new("force-override")
.long("force-override")
.short('f')
.help("Forces the override of existing vscode tasks")
.required(false),
.action(ArgAction::SetTrue)
.help("Forces the override of existing vscode tasks"),
]),
]),
Command::new("remove")
Expand Down Expand Up @@ -295,6 +307,7 @@ fn get_clap_config() -> ArgMatches {
.help("The new name of the lint"),
Arg::new("uplift")
.long("uplift")
.action(ArgAction::SetTrue)
.help("This lint will be uplifted into rustc"),
]),
Command::new("deprecate").about("Deprecates the given lint").args([
Expand All @@ -305,8 +318,6 @@ fn get_clap_config() -> ArgMatches {
Arg::new("reason")
.long("reason")
.short('r')
.required(false)
.takes_value(true)
.help("The reason for deprecation"),
]),
])
Expand Down
Loading

0 comments on commit e7fe1f9

Please sign in to comment.