mirror of
https://github.com/rust-lang/cargo.git
synced 2025-09-28 11:20:36 +00:00
feat: stabilize auto fix note
This commit is contained in:
parent
0849a28cc2
commit
6131222ba2
@ -1281,7 +1281,7 @@ impl<'cfg> DrainState<'cfg> {
|
|||||||
n => drop(write!(message, " ({} duplicates)", n)),
|
n => drop(write!(message, " ({} duplicates)", n)),
|
||||||
}
|
}
|
||||||
// Only show the `cargo fix` message if its a local `Unit`
|
// Only show the `cargo fix` message if its a local `Unit`
|
||||||
if unit.is_local() && config.nightly_features_allowed {
|
if unit.is_local() {
|
||||||
// Do not show this if there are any errors or no fixable warnings
|
// Do not show this if there are any errors or no fixable warnings
|
||||||
if let FixableWarnings::Positive(fixable) = count.fixable {
|
if let FixableWarnings::Positive(fixable) = count.fixable {
|
||||||
// `cargo fix` doesnt have an option for custom builds
|
// `cargo fix` doesnt have an option for custom builds
|
||||||
|
@ -1193,38 +1193,10 @@ fn check_fixable_warning() {
|
|||||||
.build();
|
.build();
|
||||||
|
|
||||||
foo.cargo("check")
|
foo.cargo("check")
|
||||||
.masquerade_as_nightly_cargo(&["auto-fix note"])
|
|
||||||
.with_stderr_contains("[..] (run `cargo fix --lib -p foo` to apply 1 suggestion)")
|
.with_stderr_contains("[..] (run `cargo fix --lib -p foo` to apply 1 suggestion)")
|
||||||
.run();
|
.run();
|
||||||
}
|
}
|
||||||
|
|
||||||
#[cargo_test]
|
|
||||||
fn check_fixable_not_nightly() {
|
|
||||||
let foo = project()
|
|
||||||
.file(
|
|
||||||
"Cargo.toml",
|
|
||||||
r#"
|
|
||||||
[package]
|
|
||||||
name = "foo"
|
|
||||||
version = "0.0.1"
|
|
||||||
"#,
|
|
||||||
)
|
|
||||||
.file("src/lib.rs", "use std::io;")
|
|
||||||
.build();
|
|
||||||
|
|
||||||
let rustc_message = raw_rustc_output(&foo, "src/lib.rs", &[]);
|
|
||||||
let expected_output = format!(
|
|
||||||
"\
|
|
||||||
[CHECKING] foo v0.0.1 ([..])
|
|
||||||
{}\
|
|
||||||
[WARNING] `foo` (lib) generated 1 warning
|
|
||||||
[FINISHED] dev [unoptimized + debuginfo] target(s) in [..]
|
|
||||||
",
|
|
||||||
rustc_message
|
|
||||||
);
|
|
||||||
foo.cargo("check").with_stderr(expected_output).run();
|
|
||||||
}
|
|
||||||
|
|
||||||
#[cargo_test]
|
#[cargo_test]
|
||||||
fn check_fixable_test_warning() {
|
fn check_fixable_test_warning() {
|
||||||
let foo = project()
|
let foo = project()
|
||||||
@ -1250,7 +1222,6 @@ mod tests {
|
|||||||
.build();
|
.build();
|
||||||
|
|
||||||
foo.cargo("check --all-targets")
|
foo.cargo("check --all-targets")
|
||||||
.masquerade_as_nightly_cargo(&["auto-fix note"])
|
|
||||||
.with_stderr_contains("[..] (run `cargo fix --lib -p foo --tests` to apply 1 suggestion)")
|
.with_stderr_contains("[..] (run `cargo fix --lib -p foo --tests` to apply 1 suggestion)")
|
||||||
.run();
|
.run();
|
||||||
foo.cargo("fix --lib -p foo --tests --allow-no-vcs").run();
|
foo.cargo("fix --lib -p foo --tests --allow-no-vcs").run();
|
||||||
@ -1285,7 +1256,6 @@ fn check_fixable_error_no_fix() {
|
|||||||
rustc_message
|
rustc_message
|
||||||
);
|
);
|
||||||
foo.cargo("check")
|
foo.cargo("check")
|
||||||
.masquerade_as_nightly_cargo(&["auto-fix note"])
|
|
||||||
.with_status(101)
|
.with_status(101)
|
||||||
.with_stderr(expected_output)
|
.with_stderr(expected_output)
|
||||||
.run();
|
.run();
|
||||||
@ -1325,7 +1295,6 @@ fn check_fixable_warning_workspace() {
|
|||||||
.build();
|
.build();
|
||||||
|
|
||||||
p.cargo("check")
|
p.cargo("check")
|
||||||
.masquerade_as_nightly_cargo(&["auto-fix note"])
|
|
||||||
.with_stderr_contains("[..] (run `cargo fix --lib -p foo` to apply 1 suggestion)")
|
.with_stderr_contains("[..] (run `cargo fix --lib -p foo` to apply 1 suggestion)")
|
||||||
.with_stderr_contains("[..] (run `cargo fix --lib -p bar` to apply 1 suggestion)")
|
.with_stderr_contains("[..] (run `cargo fix --lib -p bar` to apply 1 suggestion)")
|
||||||
.run();
|
.run();
|
||||||
@ -1350,7 +1319,6 @@ fn check_fixable_example() {
|
|||||||
.file("examples/ex1.rs", "use std::fmt; fn main() {}")
|
.file("examples/ex1.rs", "use std::fmt; fn main() {}")
|
||||||
.build();
|
.build();
|
||||||
p.cargo("check --all-targets")
|
p.cargo("check --all-targets")
|
||||||
.masquerade_as_nightly_cargo(&["auto-fix note"])
|
|
||||||
.with_stderr_contains("[..] (run `cargo fix --example \"ex1\"` to apply 1 suggestion)")
|
.with_stderr_contains("[..] (run `cargo fix --example \"ex1\"` to apply 1 suggestion)")
|
||||||
.run();
|
.run();
|
||||||
}
|
}
|
||||||
@ -1393,7 +1361,6 @@ fn check_fixable_bench() {
|
|||||||
)
|
)
|
||||||
.build();
|
.build();
|
||||||
p.cargo("check --all-targets")
|
p.cargo("check --all-targets")
|
||||||
.masquerade_as_nightly_cargo(&["auto-fix note"])
|
|
||||||
.with_stderr_contains("[..] (run `cargo fix --bench \"bench\"` to apply 1 suggestion)")
|
.with_stderr_contains("[..] (run `cargo fix --bench \"bench\"` to apply 1 suggestion)")
|
||||||
.run();
|
.run();
|
||||||
}
|
}
|
||||||
@ -1441,7 +1408,6 @@ fn check_fixable_mixed() {
|
|||||||
)
|
)
|
||||||
.build();
|
.build();
|
||||||
p.cargo("check --all-targets")
|
p.cargo("check --all-targets")
|
||||||
.masquerade_as_nightly_cargo(&["auto-fix note"])
|
|
||||||
.with_stderr_contains("[..] (run `cargo fix --bin \"foo\" --tests` to apply 2 suggestions)")
|
.with_stderr_contains("[..] (run `cargo fix --bin \"foo\" --tests` to apply 2 suggestions)")
|
||||||
.with_stderr_contains("[..] (run `cargo fix --example \"ex1\"` to apply 1 suggestion)")
|
.with_stderr_contains("[..] (run `cargo fix --example \"ex1\"` to apply 1 suggestion)")
|
||||||
.with_stderr_contains("[..] (run `cargo fix --bench \"bench\"` to apply 1 suggestion)")
|
.with_stderr_contains("[..] (run `cargo fix --bench \"bench\"` to apply 1 suggestion)")
|
||||||
@ -1490,7 +1456,6 @@ fn check_fixable_warning_for_clippy() {
|
|||||||
"RUSTC_WORKSPACE_WRAPPER",
|
"RUSTC_WORKSPACE_WRAPPER",
|
||||||
clippy_driver.bin("clippy-driver"),
|
clippy_driver.bin("clippy-driver"),
|
||||||
)
|
)
|
||||||
.masquerade_as_nightly_cargo(&["auto-fix note"])
|
|
||||||
.with_stderr_contains("[..] (run `cargo clippy --fix --lib -p foo` to apply 1 suggestion)")
|
.with_stderr_contains("[..] (run `cargo clippy --fix --lib -p foo` to apply 1 suggestion)")
|
||||||
.run();
|
.run();
|
||||||
}
|
}
|
||||||
|
@ -2045,7 +2045,6 @@ fn no_auto_fix_note() {
|
|||||||
// This is checked by matching the full output as `with_stderr_does_not_contain`
|
// This is checked by matching the full output as `with_stderr_does_not_contain`
|
||||||
// can be brittle
|
// can be brittle
|
||||||
cargo_process("install auto_fix")
|
cargo_process("install auto_fix")
|
||||||
.masquerade_as_nightly_cargo(&["auto-fix note"])
|
|
||||||
.with_stderr(
|
.with_stderr(
|
||||||
"\
|
"\
|
||||||
[UPDATING] `[..]` index
|
[UPDATING] `[..]` index
|
||||||
|
@ -60,7 +60,7 @@ fn deduplicate_messages_basic() {
|
|||||||
let rustc_message = raw_rustc_output(&p, "src/lib.rs", &[]);
|
let rustc_message = raw_rustc_output(&p, "src/lib.rs", &[]);
|
||||||
let expected_output = format!(
|
let expected_output = format!(
|
||||||
"{}\
|
"{}\
|
||||||
warning: `foo` (lib) generated 1 warning
|
warning: `foo` (lib) generated 1 warning (run `cargo fix --lib -p foo` to apply 1 suggestion)
|
||||||
warning: `foo` (lib test) generated 1 warning (1 duplicate)
|
warning: `foo` (lib test) generated 1 warning (1 duplicate)
|
||||||
[FINISHED] [..]
|
[FINISHED] [..]
|
||||||
[EXECUTABLE] unittests src/lib.rs (target/debug/deps/foo-[..][EXE])
|
[EXECUTABLE] unittests src/lib.rs (target/debug/deps/foo-[..][EXE])
|
||||||
@ -103,7 +103,7 @@ fn deduplicate_messages_mismatched_warnings() {
|
|||||||
let expected_output = format!(
|
let expected_output = format!(
|
||||||
"\
|
"\
|
||||||
{}\
|
{}\
|
||||||
warning: `foo` (lib) generated 1 warning
|
warning: `foo` (lib) generated 1 warning (run `cargo fix --lib -p foo` to apply 1 suggestion)
|
||||||
{}\
|
{}\
|
||||||
warning: `foo` (lib test) generated 2 warnings (1 duplicate)
|
warning: `foo` (lib test) generated 2 warnings (1 duplicate)
|
||||||
[FINISHED] [..]
|
[FINISHED] [..]
|
||||||
|
Loading…
x
Reference in New Issue
Block a user