Open
Description
Problem
With resolver = "2"
, and a workspace with a proc-macro, duplicates of a shared dependency are not displayed in cargo tree
in some situations.
Steps
The following cargo test demonstrates the problem.
#[cargo_test]
fn internal_default_features_twice() {
// Test for new resolver where a shared dependency only differs in whether
// or not it has the "default" feature enabled.
// There was an issue where `cargo tree` was incorrectly merging it in the
// output.
let p = project()
.file(
"Cargo.toml",
r#"
[workspace]
resolver = "2"
members = ["foo", "foo_derive", "shared"]
"#,
)
.file(
"foo/Cargo.toml",
r#"
[package]
name = "foo"
version = "0.1.0"
[dependencies]
shared = {path="../shared", default-features=false}
[features]
default = ["std"]
std = ["shared/std"]
"#,
)
.file("foo/src/lib.rs", "")
.file(
"foo_derive/Cargo.toml",
r#"
[package]
name = "foo_derive"
version = "0.1.0"
[lib]
proc-macro = true
[dependencies]
foo = {path="../foo"}
"#,
)
.file("foo_derive/src/lib.rs", "")
.file(
"shared/Cargo.toml",
r#"
[package]
name = "shared"
version = "0.1.0"
[features]
default = ["std"]
std = []
"#,
)
.file("shared/src/lib.rs", "")
.build();
p.cargo("tree -f")
.arg("{p} ({f})")
.with_stdout(
"\
foo [..] (default,std)
└── shared [..] (default,std)
foo_derive (proc-macro) [..] ()
└── foo [..] (default,std)
└── shared [..] (std)
shared [..] (default,std)
",
)
.run();
}
The problem is that cargo currently shows:
foo_derive v0.1.0 (proc-macro) ()
└── foo v0.1.0 (default,std) (*)
Indicating that the proc-macro is using the same foo
. However it is not, foo
is built twice. Once as a workspace root (with a dependency on shared
with default,std
features), and once as a proc-macro dependency (with a dependency on shared
with only the std
feature).
Possible Solution(s)
No response
Notes
No response
Version
cargo 1.62.0-nightly (f63f23ff1 2022-04-28)