Skip to content

Commit dc0eefb

Browse files
committed
fix(check): fix the suggested fix command by always using -p
1 parent 0fe3876 commit dc0eefb

File tree

2 files changed

+8
-15
lines changed

2 files changed

+8
-15
lines changed

src/cargo/core/compiler/job_queue/mod.rs

Lines changed: 2 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -1085,15 +1085,8 @@ impl<'gctx> DrainState<'gctx> {
10851085
Some(wrapper) if wrapper == clippy => "cargo clippy --fix",
10861086
_ => "cargo fix",
10871087
};
1088-
let mut args = {
1089-
let named = unit.target.description_named();
1090-
// if its a lib we need to add the package to fix
1091-
if unit.target.is_lib() {
1092-
format!("{} -p {}", named, unit.pkg.name())
1093-
} else {
1094-
named
1095-
}
1096-
};
1088+
let mut args =
1089+
format!("{} -p {}", unit.target.description_named(), unit.pkg.name());
10971090
if unit.mode.is_rustc_test()
10981091
&& !(unit.target.is_test() || unit.target.is_bench())
10991092
{

tests/testsuite/check.rs

Lines changed: 6 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -532,7 +532,7 @@ fn check_virtual_manifest_one_bin_project_not_in_default_members() {
532532
.build();
533533

534534
p.cargo("check -p bar")
535-
.with_stderr_contains("[..]run `cargo fix --bin \"bar\"` to apply[..]")
535+
.with_stderr_contains("[..]run `cargo fix --bin \"bar\" -p bar` to apply[..]")
536536
.run();
537537
}
538538

@@ -1421,7 +1421,7 @@ fn check_fixable_example() {
14211421
p.cargo("check --all-targets")
14221422
.with_stderr_data(str![[r#"
14231423
...
1424-
[WARNING] `foo` (example "ex1") generated 1 warning (run `cargo fix --example "ex1"` to apply 1 suggestion)
1424+
[WARNING] `foo` (example "ex1") generated 1 warning (run `cargo fix --example "ex1" -p foo` to apply 1 suggestion)
14251425
...
14261426
"#]])
14271427
.run();
@@ -1467,7 +1467,7 @@ fn check_fixable_bench() {
14671467
p.cargo("check --all-targets")
14681468
.with_stderr_data(str![[r#"
14691469
...
1470-
[WARNING] `foo` (bench "bench") generated 1 warning (run `cargo fix --bench "bench"` to apply 1 suggestion)
1470+
[WARNING] `foo` (bench "bench") generated 1 warning (run `cargo fix --bench "bench" -p foo` to apply 1 suggestion)
14711471
...
14721472
"#]])
14731473
.run();
@@ -1517,9 +1517,9 @@ fn check_fixable_mixed() {
15171517
.build();
15181518
p.cargo("check --all-targets")
15191519
.with_stderr_data(str![[r#"
1520-
[WARNING] `foo` (example "ex1") generated 1 warning (run `cargo fix --example "ex1"` to apply 1 suggestion)
1521-
[WARNING] `foo` (bench "bench") generated 1 warning (run `cargo fix --bench "bench"` to apply 1 suggestion)
1522-
[WARNING] `foo` (bin "foo" test) generated 2 warnings (run `cargo fix --bin "foo" --tests` to apply 2 suggestions)
1520+
[WARNING] `foo` (example "ex1") generated 1 warning (run `cargo fix --example "ex1" -p foo` to apply 1 suggestion)
1521+
[WARNING] `foo` (bench "bench") generated 1 warning (run `cargo fix --bench "bench" -p foo` to apply 1 suggestion)
1522+
[WARNING] `foo` (bin "foo" test) generated 2 warnings (run `cargo fix --bin "foo" -p foo --tests` to apply 2 suggestions)
15231523
...
15241524
"#]].unordered())
15251525
.run();

0 commit comments

Comments
 (0)