Skip to content

Commit 6c095cc

Browse files
committed
Auto merge of #11558 - Muscraft:stabilize-cargo-fix-message, r=epage
feat: stabilize auto fix note A note that some warnings could be fixed by running a `cargo fix` command was added in #10989 and made to work with `clippy` in #11399. It has only been turned on for `nightly` builds so far; this PR would make it show on `stable`. The original motivation for making this note `nightly` only, was to [allow for iteration](#10976 (comment)) on the message output. There has yet to be any feedback on the message format in the time that it has been on `nightly`. This was brought up in a recent cargo team meeting and it was thought that we should move forward with showing this on `stable`. close #10976
2 parents 96d5330 + 6131222 commit 6c095cc

File tree

4 files changed

+3
-39
lines changed

4 files changed

+3
-39
lines changed

src/cargo/core/compiler/job_queue.rs

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1281,7 +1281,7 @@ impl<'cfg> DrainState<'cfg> {
12811281
n => drop(write!(message, " ({} duplicates)", n)),
12821282
}
12831283
// Only show the `cargo fix` message if its a local `Unit`
1284-
if unit.is_local() && config.nightly_features_allowed {
1284+
if unit.is_local() {
12851285
// Do not show this if there are any errors or no fixable warnings
12861286
if let FixableWarnings::Positive(fixable) = count.fixable {
12871287
// `cargo fix` doesnt have an option for custom builds

tests/testsuite/check.rs

Lines changed: 0 additions & 35 deletions
Original file line numberDiff line numberDiff line change
@@ -1193,38 +1193,10 @@ fn check_fixable_warning() {
11931193
.build();
11941194

11951195
foo.cargo("check")
1196-
.masquerade_as_nightly_cargo(&["auto-fix note"])
11971196
.with_stderr_contains("[..] (run `cargo fix --lib -p foo` to apply 1 suggestion)")
11981197
.run();
11991198
}
12001199

1201-
#[cargo_test]
1202-
fn check_fixable_not_nightly() {
1203-
let foo = project()
1204-
.file(
1205-
"Cargo.toml",
1206-
r#"
1207-
[package]
1208-
name = "foo"
1209-
version = "0.0.1"
1210-
"#,
1211-
)
1212-
.file("src/lib.rs", "use std::io;")
1213-
.build();
1214-
1215-
let rustc_message = raw_rustc_output(&foo, "src/lib.rs", &[]);
1216-
let expected_output = format!(
1217-
"\
1218-
[CHECKING] foo v0.0.1 ([..])
1219-
{}\
1220-
[WARNING] `foo` (lib) generated 1 warning
1221-
[FINISHED] dev [unoptimized + debuginfo] target(s) in [..]
1222-
",
1223-
rustc_message
1224-
);
1225-
foo.cargo("check").with_stderr(expected_output).run();
1226-
}
1227-
12281200
#[cargo_test]
12291201
fn check_fixable_test_warning() {
12301202
let foo = project()
@@ -1250,7 +1222,6 @@ mod tests {
12501222
.build();
12511223

12521224
foo.cargo("check --all-targets")
1253-
.masquerade_as_nightly_cargo(&["auto-fix note"])
12541225
.with_stderr_contains("[..] (run `cargo fix --lib -p foo --tests` to apply 1 suggestion)")
12551226
.run();
12561227
foo.cargo("fix --lib -p foo --tests --allow-no-vcs").run();
@@ -1285,7 +1256,6 @@ fn check_fixable_error_no_fix() {
12851256
rustc_message
12861257
);
12871258
foo.cargo("check")
1288-
.masquerade_as_nightly_cargo(&["auto-fix note"])
12891259
.with_status(101)
12901260
.with_stderr(expected_output)
12911261
.run();
@@ -1325,7 +1295,6 @@ fn check_fixable_warning_workspace() {
13251295
.build();
13261296

13271297
p.cargo("check")
1328-
.masquerade_as_nightly_cargo(&["auto-fix note"])
13291298
.with_stderr_contains("[..] (run `cargo fix --lib -p foo` to apply 1 suggestion)")
13301299
.with_stderr_contains("[..] (run `cargo fix --lib -p bar` to apply 1 suggestion)")
13311300
.run();
@@ -1350,7 +1319,6 @@ fn check_fixable_example() {
13501319
.file("examples/ex1.rs", "use std::fmt; fn main() {}")
13511320
.build();
13521321
p.cargo("check --all-targets")
1353-
.masquerade_as_nightly_cargo(&["auto-fix note"])
13541322
.with_stderr_contains("[..] (run `cargo fix --example \"ex1\"` to apply 1 suggestion)")
13551323
.run();
13561324
}
@@ -1393,7 +1361,6 @@ fn check_fixable_bench() {
13931361
)
13941362
.build();
13951363
p.cargo("check --all-targets")
1396-
.masquerade_as_nightly_cargo(&["auto-fix note"])
13971364
.with_stderr_contains("[..] (run `cargo fix --bench \"bench\"` to apply 1 suggestion)")
13981365
.run();
13991366
}
@@ -1441,7 +1408,6 @@ fn check_fixable_mixed() {
14411408
)
14421409
.build();
14431410
p.cargo("check --all-targets")
1444-
.masquerade_as_nightly_cargo(&["auto-fix note"])
14451411
.with_stderr_contains("[..] (run `cargo fix --bin \"foo\" --tests` to apply 2 suggestions)")
14461412
.with_stderr_contains("[..] (run `cargo fix --example \"ex1\"` to apply 1 suggestion)")
14471413
.with_stderr_contains("[..] (run `cargo fix --bench \"bench\"` to apply 1 suggestion)")
@@ -1490,7 +1456,6 @@ fn check_fixable_warning_for_clippy() {
14901456
"RUSTC_WORKSPACE_WRAPPER",
14911457
clippy_driver.bin("clippy-driver"),
14921458
)
1493-
.masquerade_as_nightly_cargo(&["auto-fix note"])
14941459
.with_stderr_contains("[..] (run `cargo clippy --fix --lib -p foo` to apply 1 suggestion)")
14951460
.run();
14961461
}

tests/testsuite/install.rs

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -2083,7 +2083,6 @@ fn no_auto_fix_note() {
20832083
// This is checked by matching the full output as `with_stderr_does_not_contain`
20842084
// can be brittle
20852085
cargo_process("install auto_fix")
2086-
.masquerade_as_nightly_cargo(&["auto-fix note"])
20872086
.with_stderr(
20882087
"\
20892088
[UPDATING] `[..]` index

tests/testsuite/messages.rs

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -60,7 +60,7 @@ fn deduplicate_messages_basic() {
6060
let rustc_message = raw_rustc_output(&p, "src/lib.rs", &[]);
6161
let expected_output = format!(
6262
"{}\
63-
warning: `foo` (lib) generated 1 warning
63+
warning: `foo` (lib) generated 1 warning (run `cargo fix --lib -p foo` to apply 1 suggestion)
6464
warning: `foo` (lib test) generated 1 warning (1 duplicate)
6565
[FINISHED] [..]
6666
[EXECUTABLE] unittests src/lib.rs (target/debug/deps/foo-[..][EXE])
@@ -103,7 +103,7 @@ fn deduplicate_messages_mismatched_warnings() {
103103
let expected_output = format!(
104104
"\
105105
{}\
106-
warning: `foo` (lib) generated 1 warning
106+
warning: `foo` (lib) generated 1 warning (run `cargo fix --lib -p foo` to apply 1 suggestion)
107107
{}\
108108
warning: `foo` (lib test) generated 2 warnings (1 duplicate)
109109
[FINISHED] [..]

0 commit comments

Comments
 (0)