Skip to content

Commit b068b74

Browse files
committed
lintcheck: fix --fix and document it in the readme.
also hook lintcheck into clippy-dev so that `clippy dev fmt` formats it.
1 parent b29ef18 commit b068b74

File tree

3 files changed

+12
-1
lines changed

3 files changed

+12
-1
lines changed

clippy_dev/src/fmt.rs

Lines changed: 1 addition & 0 deletions
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?;

lintcheck/README.md

Lines changed: 6 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -67,3 +67,9 @@ is checked.
6767

6868
**Note:** `-Wclippy::all` is always enabled by default, unless `-Aclippy::all`
6969
is explicitly specified in the options.
70+
71+
### Fix mode
72+
You can run `./lintcheck/target/debug/lintcheck --fix` which will run Clippy with `-Zunstable-options --fix` and print a warning if Clippys suggestions fail to apply (if the resulting code does not build).
73+
This lets us spot bad suggestions or false positives automatically in some cases.
74+
75+
Please note that the target dir should be cleaned afterwards since clippy will modify the downloaded sources which can lead to unexpected results when running lintcheck again afterwards.

lintcheck/src/main.rs

Lines changed: 5 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -862,7 +862,11 @@ fn get_clap_config<'a>() -> ArgMatches<'a> {
862862
.long("jobs")
863863
.help("number of threads to use, 0 automatic choice"),
864864
)
865-
.arg(Arg::with_name("fix").help("runs cargo clippy --fix and checks if all suggestions apply"))
865+
.arg(
866+
Arg::with_name("fix")
867+
.long("--fix")
868+
.help("runs cargo clippy --fix and checks if all suggestions apply"),
869+
)
866870
.get_matches()
867871
}
868872

0 commit comments

Comments
 (0)