Skip to content

Commit 95c2ab7

Browse files
committed
Auto merge of #7405 - jyn514:fix-stable, r=camsteffen
Stabilize `cargo clippy --fix` This has been unstable since it was first introduced in rust-lang/rust-clippy#5363. In that time, I have been using it successfully in nightly without issues. I don't think there are any blocking issues now that RUSTC_WORKSPACE_WRAPPER is stabilized, so this can be stabilized. changelog: Stabilize `cargo clippy --fix`
2 parents f4bc9cf + aa40487 commit 95c2ab7

File tree

6 files changed

+10
-36
lines changed

6 files changed

+10
-36
lines changed

.github/workflows/clippy.yml

+1-1
Original file line numberDiff line numberDiff line change
@@ -71,7 +71,7 @@ jobs:
7171
working-directory: clippy_workspace_tests
7272

7373
- name: Test cargo-clippy --fix
74-
run: ../target/debug/cargo-clippy clippy --fix -Zunstable-options
74+
run: ../target/debug/cargo-clippy clippy --fix
7575
working-directory: clippy_workspace_tests
7676

7777
- name: Test clippy-driver

.github/workflows/clippy_bors.yml

+1-1
Original file line numberDiff line numberDiff line change
@@ -134,7 +134,7 @@ jobs:
134134
working-directory: clippy_workspace_tests
135135

136136
- name: Test cargo-clippy --fix
137-
run: ../target/debug/cargo-clippy clippy --fix -Zunstable-options
137+
run: ../target/debug/cargo-clippy clippy --fix
138138
working-directory: clippy_workspace_tests
139139

140140
- name: Test clippy-driver

README.md

+2-3
Original file line numberDiff line numberDiff line change
@@ -76,11 +76,10 @@ cargo clippy
7676

7777
#### Automatically applying Clippy suggestions
7878

79-
Clippy can automatically apply some lint suggestions.
80-
Note that this is still experimental and only supported on the nightly channel:
79+
Clippy can automatically apply some lint suggestions, just like the compiler.
8180

8281
```terminal
83-
cargo clippy --fix -Z unstable-options
82+
cargo clippy --fix
8483
```
8584

8685
#### Workspaces

lintcheck/README.md

+1-1
Original file line numberDiff line numberDiff line change
@@ -69,7 +69,7 @@ is checked.
6969
is explicitly specified in the options.
7070

7171
### Fix mode
72-
You can run `./lintcheck/target/debug/lintcheck --fix` which will run Clippy with `-Zunstable-options --fix` and
72+
You can run `./lintcheck/target/debug/lintcheck --fix` which will run Clippy with `--fix` and
7373
print a warning if Clippys suggestions fail to apply (if the resulting code does not build).
7474
This lets us spot bad suggestions or false positives automatically in some cases.
7575

lintcheck/src/main.rs

+1-8
Original file line numberDiff line numberDiff line change
@@ -260,14 +260,7 @@ impl Crate {
260260
let shared_target_dir = clippy_project_root().join("target/lintcheck/shared_target_dir");
261261

262262
let mut args = if fix {
263-
vec![
264-
"-Zunstable-options",
265-
"--fix",
266-
"-Zunstable-options",
267-
"--allow-no-vcs",
268-
"--",
269-
"--cap-lints=warn",
270-
]
263+
vec!["--fix", "--allow-no-vcs", "--", "--cap-lints=warn"]
271264
} else {
272265
vec!["--", "--message-format=json", "--", "--cap-lints=warn"]
273266
};

src/main.rs

+4-22
Original file line numberDiff line numberDiff line change
@@ -70,7 +70,6 @@ impl ClippyCmd {
7070
I: Iterator<Item = String>,
7171
{
7272
let mut cargo_subcommand = "check";
73-
let mut unstable_options = false;
7473
let mut args = vec![];
7574

7675
for arg in old_args.by_ref() {
@@ -80,18 +79,12 @@ impl ClippyCmd {
8079
continue;
8180
},
8281
"--" => break,
83-
// Cover -Zunstable-options and -Z unstable-options
84-
s if s.ends_with("unstable-options") => unstable_options = true,
8582
_ => {},
8683
}
8784

8885
args.push(arg);
8986
}
9087

91-
if cargo_subcommand == "fix" && !unstable_options {
92-
panic!("Usage of `--fix` requires `-Z unstable-options`");
93-
}
94-
9588
let mut clippy_args: Vec<String> = old_args.collect();
9689
if cargo_subcommand == "fix" && !clippy_args.iter().any(|arg| arg == "--no-deps") {
9790
clippy_args.push("--no-deps".into());
@@ -176,34 +169,23 @@ mod tests {
176169
use super::ClippyCmd;
177170

178171
#[test]
179-
#[should_panic]
180-
fn fix_without_unstable() {
172+
fn fix() {
181173
let args = "cargo clippy --fix".split_whitespace().map(ToString::to_string);
182-
ClippyCmd::new(args);
183-
}
184-
185-
#[test]
186-
fn fix_unstable() {
187-
let args = "cargo clippy --fix -Zunstable-options"
188-
.split_whitespace()
189-
.map(ToString::to_string);
190174
let cmd = ClippyCmd::new(args);
191175
assert_eq!("fix", cmd.cargo_subcommand);
192-
assert!(cmd.args.iter().any(|arg| arg.ends_with("unstable-options")));
176+
assert!(!cmd.args.iter().any(|arg| arg.ends_with("unstable-options")));
193177
}
194178

195179
#[test]
196180
fn fix_implies_no_deps() {
197-
let args = "cargo clippy --fix -Zunstable-options"
198-
.split_whitespace()
199-
.map(ToString::to_string);
181+
let args = "cargo clippy --fix".split_whitespace().map(ToString::to_string);
200182
let cmd = ClippyCmd::new(args);
201183
assert!(cmd.clippy_args.iter().any(|arg| arg == "--no-deps"));
202184
}
203185

204186
#[test]
205187
fn no_deps_not_duplicated_with_fix() {
206-
let args = "cargo clippy --fix -Zunstable-options -- --no-deps"
188+
let args = "cargo clippy --fix -- --no-deps"
207189
.split_whitespace()
208190
.map(ToString::to_string);
209191
let cmd = ClippyCmd::new(args);

0 commit comments

Comments
 (0)