Skip to content

Commit 534a13d

Browse files
committed
Auto merge of rust-lang#6884 - matthiaskrgr:lintcheck_crate, r=Manishearth
move lintcheck into its own crate This pr: * moves lintcheck out of `clippy dev` and into its own crate (`lintcheck`) (I should have done this earlier :D) * makes lintcheck terminate if it is not launched from the repo root (to prevent problems with wrong paths when using `cargo run` in the crate root) * fixes json lint messages leaking the runners `$HOME` when a lint messages comes from a proc macro that originates from a crate inside the `$CARGO_CACHE` * adds more documentation to lintchecks `README.md` and mentions lintcheck in `docs/basics.md` changelog: none
2 parents 99afc6e + 0af90fd commit 534a13d

File tree

13 files changed

+475
-234
lines changed

13 files changed

+475
-234
lines changed

.cargo/config

+1-1
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,7 @@
11
[alias]
22
uitest = "test --test compile-test"
33
dev = "run --target-dir clippy_dev/target --package clippy_dev --bin clippy_dev --manifest-path clippy_dev/Cargo.toml --"
4-
dev-lintcheck = "run --target-dir clippy_dev/target --package clippy_dev --bin clippy_dev --manifest-path clippy_dev/Cargo.toml --features lintcheck -- lintcheck"
4+
lintcheck = "run --target-dir lintcheck/target --package lintcheck --bin lintcheck --manifest-path lintcheck/Cargo.toml -- "
55

66
[build]
77
rustflags = ["-Zunstable-options"]

.gitignore

+1
Original file line numberDiff line numberDiff line change
@@ -21,6 +21,7 @@ out
2121
/clippy_utils/target
2222
/clippy_workspace_tests/target
2323
/clippy_dev/target
24+
/lintcheck/target
2425
/rustc_tools_util/target
2526

2627
# Generated by dogfood

clippy_dev/Cargo.toml

-9
Original file line numberDiff line numberDiff line change
@@ -7,20 +7,11 @@ edition = "2018"
77
[dependencies]
88
bytecount = "0.6"
99
clap = "2.33"
10-
flate2 = { version = "1.0.19", optional = true }
11-
fs_extra = { version = "1.2.0", optional = true }
1210
itertools = "0.9"
1311
opener = "0.4"
1412
regex = "1"
15-
serde = { version = "1.0", features = ["derive"], optional = true }
16-
serde_json = { version = "1.0", optional = true }
1713
shell-escape = "0.1"
18-
tar = { version = "0.4.30", optional = true }
19-
toml = { version = "0.5", optional = true }
20-
ureq = { version = "2.0.0-rc3", optional = true }
21-
rayon = { version = "1.5.0", optional = true }
2214
walkdir = "2"
2315

2416
[features]
25-
lintcheck = ["flate2", "serde_json", "tar", "toml", "ureq", "serde", "fs_extra", "rayon"]
2617
deny-warnings = []

clippy_dev/src/fmt.rs

+1
Original file line numberDiff line numberDiff line change
@@ -54,6 +54,7 @@ pub fn run(check: bool, verbose: bool) {
5454
success &= cargo_fmt(context, project_root.as_path())?;
5555
success &= cargo_fmt(context, &project_root.join("clippy_dev"))?;
5656
success &= cargo_fmt(context, &project_root.join("rustc_tools_util"))?;
57+
success &= cargo_fmt(context, &project_root.join("lintcheck"))?;
5758

5859
for entry in WalkDir::new(project_root.join("tests")) {
5960
let entry = entry?;

clippy_dev/src/lib.rs

-1
Original file line numberDiff line numberDiff line change
@@ -12,7 +12,6 @@ use walkdir::WalkDir;
1212

1313
pub mod bless;
1414
pub mod fmt;
15-
pub mod lintcheck;
1615
pub mod new_lint;
1716
pub mod ra_setup;
1817
pub mod serve;

clippy_dev/src/main.rs

+3-42
Original file line numberDiff line numberDiff line change
@@ -2,21 +2,13 @@
22

33
use clap::{App, Arg, ArgMatches, SubCommand};
44
use clippy_dev::{bless, fmt, new_lint, ra_setup, serve, stderr_length_check, update_lints};
5-
6-
#[cfg(feature = "lintcheck")]
7-
use clippy_dev::lintcheck;
8-
95
fn main() {
106
let matches = get_clap_config();
117

128
match matches.subcommand() {
139
("bless", Some(matches)) => {
1410
bless::bless(matches.is_present("ignore-timestamp"));
1511
},
16-
#[cfg(feature = "lintcheck")]
17-
("lintcheck", Some(matches)) => {
18-
lintcheck::run(&matches);
19-
},
2012
("fmt", Some(matches)) => {
2113
fmt::run(matches.is_present("check"), matches.is_present("verbose"));
2214
},
@@ -53,34 +45,7 @@ fn main() {
5345
}
5446

5547
fn get_clap_config<'a>() -> ArgMatches<'a> {
56-
#[cfg(feature = "lintcheck")]
57-
let lintcheck_sbcmd = SubCommand::with_name("lintcheck")
58-
.about("run clippy on a set of crates and check output")
59-
.arg(
60-
Arg::with_name("only")
61-
.takes_value(true)
62-
.value_name("CRATE")
63-
.long("only")
64-
.help("only process a single crate of the list"),
65-
)
66-
.arg(
67-
Arg::with_name("crates-toml")
68-
.takes_value(true)
69-
.value_name("CRATES-SOURCES-TOML-PATH")
70-
.long("crates-toml")
71-
.help("set the path for a crates.toml where lintcheck should read the sources from"),
72-
)
73-
.arg(
74-
Arg::with_name("threads")
75-
.takes_value(true)
76-
.value_name("N")
77-
.short("j")
78-
.long("jobs")
79-
.help("number of threads to use, 0 automatic choice"),
80-
)
81-
.arg(Arg::with_name("fix").help("runs cargo clippy --fix and checks if all suggestions apply"));
82-
83-
let app = App::new("Clippy developer tooling")
48+
App::new("Clippy developer tooling")
8449
.subcommand(
8550
SubCommand::with_name("bless")
8651
.about("bless the test output changes")
@@ -197,10 +162,6 @@ fn get_clap_config<'a>() -> ArgMatches<'a> {
197162
.validator_os(serve::validate_port),
198163
)
199164
.arg(Arg::with_name("lint").help("Which lint's page to load initially (optional)")),
200-
);
201-
202-
#[cfg(feature = "lintcheck")]
203-
let app = app.subcommand(lintcheck_sbcmd);
204-
205-
app.get_matches()
165+
)
166+
.get_matches()
206167
}

doc/basics.md

+12-1
Original file line numberDiff line numberDiff line change
@@ -11,8 +11,9 @@ the codebase take a look at [Adding Lints] or [Common Tools].
1111
- [Get the Code](#get-the-code)
1212
- [Building and Testing](#building-and-testing)
1313
- [`cargo dev`](#cargo-dev)
14-
- [Common Abbreviations](#common-abbreviations)
14+
- [lintcheck](#lintcheck)
1515
- [PR](#pr)
16+
- [Common Abbreviations](#common-abbreviations)
1617

1718
## Get the Code
1819

@@ -91,6 +92,16 @@ cargo dev new_lint
9192
cargo dev ra_setup
9293
```
9394

95+
## lintcheck
96+
`cargo lintcheck` will build and run clippy on a fixed set of crates and generate a log of the results.
97+
You can `git diff` the updated log against its previous version and
98+
see what impact your lint made on a small set of crates.
99+
If you add a new lint, please audit the resulting warnings and make sure
100+
there are no false positives and that the suggestions are valid.
101+
102+
Refer to the tools [README] for more details.
103+
104+
[README]: https://github.com/rust-lang/rust-clippy/blob/master/lintcheck/README.md
94105
## PR
95106

96107
We follow a rustc no merge-commit policy.

0 commit comments

Comments
 (0)