Skip to content
This repository was archived by the owner on May 28, 2025. It is now read-only.

Commit bb4781a

Browse files
committed
Auto merge of rust-lang#97248 - xFrednet:clippyup, r=Manishearth
Clippyup This direction was simpler. All test Clippy pass locally 🙃 r? `@Manishearth`
2 parents 74b1369 + 6e87c24 commit bb4781a

File tree

240 files changed

+4453
-1715
lines changed

Some content is hidden

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

240 files changed

+4453
-1715
lines changed

Cargo.lock

Lines changed: 4 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -627,7 +627,7 @@ dependencies = [
627627

628628
[[package]]
629629
name = "clippy"
630-
version = "0.1.62"
630+
version = "0.1.63"
631631
dependencies = [
632632
"clippy_lints",
633633
"clippy_utils",
@@ -647,6 +647,7 @@ dependencies = [
647647
"serde",
648648
"syn",
649649
"tempfile",
650+
"termize",
650651
"tester",
651652
"tokio",
652653
]
@@ -667,7 +668,7 @@ dependencies = [
667668

668669
[[package]]
669670
name = "clippy_lints"
670-
version = "0.1.62"
671+
version = "0.1.63"
671672
dependencies = [
672673
"cargo_metadata",
673674
"clippy_utils",
@@ -688,7 +689,7 @@ dependencies = [
688689

689690
[[package]]
690691
name = "clippy_utils"
691-
version = "0.1.62"
692+
version = "0.1.63"
692693
dependencies = [
693694
"arrayvec",
694695
"if_chain",

src/tools/clippy/.github/deploy.sh

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -8,6 +8,7 @@ rm -rf out/master/ || exit 0
88
echo "Making the docs for master"
99
mkdir out/master/
1010
cp util/gh-pages/index.html out/master
11+
cp util/gh-pages/script.js out/master
1112
cp util/gh-pages/lints.json out/master
1213

1314
if [[ -n $TAG_NAME ]]; then

src/tools/clippy/CHANGELOG.md

Lines changed: 42 additions & 3 deletions
Large diffs are not rendered by default.

src/tools/clippy/CONTRIBUTING.md

Lines changed: 5 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -67,9 +67,9 @@ and resolved paths.
6767

6868
[`T-AST`] issues will generally need you to match against a predefined syntax structure.
6969
To figure out how this syntax structure is encoded in the AST, it is recommended to run
70-
`rustc -Z ast-json` on an example of the structure and compare with the [nodes in the AST docs].
70+
`rustc -Z unpretty=ast-tree` on an example of the structure and compare with the [nodes in the AST docs].
7171
Usually the lint will end up to be a nested series of matches and ifs, [like so][deep-nesting].
72-
But we can make it nest-less by using [if_chain] macro, [like this][nest-less].
72+
But we can make it nest-less by using [let chains], [like this][nest-less].
7373

7474
[`E-medium`] issues are generally pretty easy too, though it's recommended you work on an [`good-first-issue`]
7575
first. Sometimes they are only somewhat involved code wise, but not difficult per-se.
@@ -87,9 +87,9 @@ an AST expression). `match_def_path()` in Clippy's `utils` module can also be us
8787
[`E-medium`]: https://github.com/rust-lang/rust-clippy/labels/E-medium
8888
[`ty`]: https://doc.rust-lang.org/nightly/nightly-rustc/rustc_middle/ty
8989
[nodes in the AST docs]: https://doc.rust-lang.org/nightly/nightly-rustc/rustc_ast/ast/
90-
[deep-nesting]: https://github.com/rust-lang/rust-clippy/blob/557f6848bd5b7183f55c1e1522a326e9e1df6030/clippy_lints/src/mem_forget.rs#L29-L43
91-
[if_chain]: https://docs.rs/if_chain/*/if_chain
92-
[nest-less]: https://github.com/rust-lang/rust-clippy/blob/557f6848bd5b7183f55c1e1522a326e9e1df6030/clippy_lints/src/bit_mask.rs#L124-L150
90+
[deep-nesting]: https://github.com/rust-lang/rust-clippy/blob/5e4f0922911536f80d9591180fa604229ac13939/clippy_lints/src/mem_forget.rs#L31-L45
91+
[let chains]: https://github.com/rust-lang/rust/pull/94927
92+
[nest-less]: https://github.com/rust-lang/rust-clippy/blob/5e4f0922911536f80d9591180fa604229ac13939/clippy_lints/src/bit_mask.rs#L133-L159
9393

9494
## Writing code
9595

src/tools/clippy/Cargo.toml

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,6 @@
11
[package]
22
name = "clippy"
3-
version = "0.1.62"
3+
version = "0.1.63"
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"
@@ -25,6 +25,7 @@ clippy_lints = { path = "clippy_lints" }
2525
semver = "1.0"
2626
rustc_tools_util = { path = "rustc_tools_util" }
2727
tempfile = { version = "3.2", optional = true }
28+
termize = "0.1"
2829

2930
[dev-dependencies]
3031
compiletest_rs = { version = "0.7.1", features = ["tmp"] }

src/tools/clippy/clippy_dev/src/lint.rs

Lines changed: 4 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -13,7 +13,7 @@ fn exit_if_err(status: io::Result<ExitStatus>) {
1313
}
1414
}
1515

16-
pub fn run(path: &str) {
16+
pub fn run<'a>(path: &str, args: impl Iterator<Item = &'a str>) {
1717
let is_file = match fs::metadata(path) {
1818
Ok(metadata) => metadata.is_file(),
1919
Err(e) => {
@@ -30,6 +30,7 @@ pub fn run(path: &str) {
3030
.args(["-Z", "no-codegen"])
3131
.args(["--edition", "2021"])
3232
.arg(path)
33+
.args(args)
3334
.status(),
3435
);
3536
} else {
@@ -42,6 +43,8 @@ pub fn run(path: &str) {
4243
.expect("failed to create tempdir");
4344

4445
let status = Command::new(cargo_clippy_path())
46+
.arg("clippy")
47+
.args(args)
4548
.current_dir(path)
4649
.env("CARGO_TARGET_DIR", target.as_ref())
4750
.status();

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

Lines changed: 15 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -76,7 +76,8 @@ fn main() {
7676
},
7777
("lint", Some(matches)) => {
7878
let path = matches.value_of("path").unwrap();
79-
lint::run(path);
79+
let args = matches.values_of("args").into_iter().flatten();
80+
lint::run(path, args);
8081
},
8182
("rename_lint", Some(matches)) => {
8283
let old_name = matches.value_of("old_name").unwrap();
@@ -123,7 +124,7 @@ fn get_clap_config<'a>() -> ArgMatches<'a> {
123124
* the lint count in README.md is correct\n \
124125
* the changelog contains markdown link references at the bottom\n \
125126
* all lint groups include the correct lints\n \
126-
* lint modules in `clippy_lints/*` are visible in `src/lifb.rs` via `pub mod`\n \
127+
* lint modules in `clippy_lints/*` are visible in `src/lib.rs` via `pub mod`\n \
127128
* all lints are registered in the lint store",
128129
)
129130
.arg(Arg::with_name("print-only").long("print-only").help(
@@ -278,11 +279,23 @@ fn get_clap_config<'a>() -> ArgMatches<'a> {
278279
Lint a package directory:
279280
cargo dev lint tests/ui-cargo/wildcard_dependencies/fail
280281
cargo dev lint ~/my-project
282+
283+
Run rustfix:
284+
cargo dev lint ~/my-project -- --fix
285+
286+
Set lint levels:
287+
cargo dev lint file.rs -- -W clippy::pedantic
288+
cargo dev lint ~/my-project -- -- -W clippy::pedantic
281289
"})
282290
.arg(
283291
Arg::with_name("path")
284292
.required(true)
285293
.help("The path to a file or package directory to lint"),
294+
)
295+
.arg(
296+
Arg::with_name("args")
297+
.multiple(true)
298+
.help("Pass extra arguments to cargo/clippy-driver"),
286299
),
287300
)
288301
.subcommand(

src/tools/clippy/clippy_dev/src/new_lint.rs

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -133,7 +133,7 @@ fn to_camel_case(name: &str) -> String {
133133
.collect()
134134
}
135135

136-
fn get_stabilisation_version() -> String {
136+
fn get_stabilization_version() -> String {
137137
fn parse_manifest(contents: &str) -> Option<String> {
138138
let version = contents
139139
.lines()
@@ -199,7 +199,7 @@ fn get_lint_file_contents(lint: &LintData<'_>, enable_msrv: bool) -> String {
199199
},
200200
};
201201

202-
let version = get_stabilisation_version();
202+
let version = get_stabilization_version();
203203
let lint_name = lint.name;
204204
let category = lint.category;
205205
let name_camel = to_camel_case(lint.name);

src/tools/clippy/clippy_dev/src/update_lints.rs

Lines changed: 10 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -17,7 +17,7 @@ const GENERATED_FILE_COMMENT: &str = "// This file was generated by `cargo dev u
1717

1818
const DOCS_LINK: &str = "https://rust-lang.github.io/rust-clippy/master/index.html";
1919

20-
#[derive(Clone, Copy, PartialEq)]
20+
#[derive(Clone, Copy, PartialEq, Eq)]
2121
pub enum UpdateMode {
2222
Check,
2323
Change,
@@ -66,8 +66,13 @@ fn generate_lint_files(
6666
|res| {
6767
for lint in usable_lints
6868
.iter()
69-
.map(|l| &l.name)
70-
.chain(deprecated_lints.iter().map(|l| &l.name))
69+
.map(|l| &*l.name)
70+
.chain(deprecated_lints.iter().map(|l| &*l.name))
71+
.chain(
72+
renamed_lints
73+
.iter()
74+
.map(|l| l.old_name.strip_prefix("clippy::").unwrap_or(&l.old_name)),
75+
)
7176
.sorted()
7277
{
7378
writeln!(res, "[`{}`]: {}#{}", lint, DOCS_LINK, lint).unwrap();
@@ -372,7 +377,7 @@ fn exit_with_failure() {
372377
}
373378

374379
/// Lint data parsed from the Clippy source code.
375-
#[derive(Clone, PartialEq, Debug)]
380+
#[derive(Clone, PartialEq, Eq, Debug)]
376381
struct Lint {
377382
name: String,
378383
group: String,
@@ -414,7 +419,7 @@ impl Lint {
414419
}
415420
}
416421

417-
#[derive(Clone, PartialEq, Debug)]
422+
#[derive(Clone, PartialEq, Eq, Debug)]
418423
struct DeprecatedLint {
419424
name: String,
420425
reason: String,

src/tools/clippy/clippy_lints/Cargo.toml

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,6 @@
11
[package]
22
name = "clippy_lints"
3-
version = "0.1.62"
3+
version = "0.1.63"
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"

0 commit comments

Comments
 (0)