Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
11 changes: 2 additions & 9 deletions src/cargo/core/compiler/job_queue/mod.rs
Original file line number Diff line number Diff line change
Expand Up @@ -1085,15 +1085,8 @@ impl<'gctx> DrainState<'gctx> {
Some(wrapper) if wrapper == clippy => "cargo clippy --fix",
_ => "cargo fix",
};
let mut args = {
let named = unit.target.description_named();
// if its a lib we need to add the package to fix
if unit.target.is_lib() {
format!("{} -p {}", named, unit.pkg.name())
} else {
named
}
};
let mut args =
format!("{} -p {}", unit.target.description_named(), unit.pkg.name());
if unit.mode.is_rustc_test()
&& !(unit.target.is_test() || unit.target.is_bench())
{
Expand Down
31 changes: 26 additions & 5 deletions tests/testsuite/check.rs
Original file line number Diff line number Diff line change
Expand Up @@ -515,6 +515,27 @@ fn check_virtual_manifest_one_project() {
.run();
}

#[cargo_test]
fn check_virtual_manifest_one_bin_project_not_in_default_members() {
let p = project()
.file(
"Cargo.toml",
r#"
[workspace]
members = ["bar"]
default-members = []
resolver = "3"
"#,
)
.file("bar/Cargo.toml", &basic_manifest("bar", "0.1.0"))
.file("bar/src/main.rs", "fn main() { let _ = (1); }")
.build();

p.cargo("check -p bar")
.with_stderr_contains("[..]run `cargo fix --bin \"bar\" -p bar` to apply[..]")
.run();
}

#[cargo_test]
fn check_virtual_manifest_glob() {
let p = project()
Expand Down Expand Up @@ -1400,7 +1421,7 @@ fn check_fixable_example() {
p.cargo("check --all-targets")
.with_stderr_data(str![[r#"
...
[WARNING] `foo` (example "ex1") generated 1 warning (run `cargo fix --example "ex1"` to apply 1 suggestion)
[WARNING] `foo` (example "ex1") generated 1 warning (run `cargo fix --example "ex1" -p foo` to apply 1 suggestion)
...
"#]])
.run();
Expand Down Expand Up @@ -1446,7 +1467,7 @@ fn check_fixable_bench() {
p.cargo("check --all-targets")
.with_stderr_data(str![[r#"
...
[WARNING] `foo` (bench "bench") generated 1 warning (run `cargo fix --bench "bench"` to apply 1 suggestion)
[WARNING] `foo` (bench "bench") generated 1 warning (run `cargo fix --bench "bench" -p foo` to apply 1 suggestion)
...
"#]])
.run();
Expand Down Expand Up @@ -1496,9 +1517,9 @@ fn check_fixable_mixed() {
.build();
p.cargo("check --all-targets")
.with_stderr_data(str![[r#"
[WARNING] `foo` (example "ex1") generated 1 warning (run `cargo fix --example "ex1"` to apply 1 suggestion)
[WARNING] `foo` (bench "bench") generated 1 warning (run `cargo fix --bench "bench"` to apply 1 suggestion)
[WARNING] `foo` (bin "foo" test) generated 2 warnings (run `cargo fix --bin "foo" --tests` to apply 2 suggestions)
[WARNING] `foo` (example "ex1") generated 1 warning (run `cargo fix --example "ex1" -p foo` to apply 1 suggestion)
[WARNING] `foo` (bench "bench") generated 1 warning (run `cargo fix --bench "bench" -p foo` to apply 1 suggestion)
[WARNING] `foo` (bin "foo" test) generated 2 warnings (run `cargo fix --bin "foo" -p foo --tests` to apply 2 suggestions)
...
"#]].unordered())
.run();
Expand Down