diff --git a/src/cargo/ops/tree/graph.rs b/src/cargo/ops/tree/graph.rs index 1b8b1ecbe0c..8e43a25b7df 100644 --- a/src/cargo/ops/tree/graph.rs +++ b/src/cargo/ops/tree/graph.rs @@ -327,22 +327,9 @@ impl<'a> Graph<'a> { .filter(|(_name, indexes)| { indexes .into_iter() - .map(|(node, _)| { - match node { - Node::Package { - package_id, - features, - .. - } => { - // Do not treat duplicates on the host or target as duplicates. - Node::Package { - package_id: package_id.clone(), - features: features.clone(), - kind: CompileKind::Host, - } - } - _ => unreachable!(), - } + .map(|(node, _)| match node { + Node::Package { package_id, .. } => package_id.clone(), + _ => unreachable!(), }) .collect::>() .len() diff --git a/tests/testsuite/cargo_tree/deps.rs b/tests/testsuite/cargo_tree/deps.rs index 07478856a47..59db48de18f 100644 --- a/tests/testsuite/cargo_tree/deps.rs +++ b/tests/testsuite/cargo_tree/deps.rs @@ -1307,6 +1307,7 @@ foo v0.1.0 ([ROOT]/foo) fn host_dep_feature() { // New feature resolver with optional build dep Package::new("optdep", "1.0.0").publish(); + Package::new("optdep", "2.0.0").publish(); Package::new("bar", "1.0.0") .add_dep(Dependency::new("optdep", "1.0").optional(true)) .publish(); @@ -1318,11 +1319,9 @@ fn host_dep_feature() { name = "foo" version = "0.1.0" - [build-dependencies] - bar = { version = "1.0", features = ["optdep"] } - [dependencies] - bar = "1.0" + optdep = "2.0" + bar = { version = "1.0", features = ["optdep"] } "#, ) .file("src/lib.rs", "") @@ -1333,10 +1332,9 @@ fn host_dep_feature() { p.cargo("tree") .with_stdout_data(str![[r#" foo v0.1.0 ([ROOT]/foo) -└── bar v1.0.0 - └── optdep v1.0.0 -[build-dependencies] -└── bar v1.0.0 (*) +├── bar v1.0.0 +│ └── optdep v1.0.0 +└── optdep v2.0.0 "#]]) .run(); @@ -1351,13 +1349,11 @@ bar v1.0.0 .run(); // invert - p.cargo("tree -i optdep") + p.cargo("tree -i optdep@1.0.0") .with_stdout_data(str![[r#" optdep v1.0.0 └── bar v1.0.0 └── foo v0.1.0 ([ROOT]/foo) - [build-dependencies] - └── foo v0.1.0 ([ROOT]/foo) "#]]) .run(); @@ -1368,10 +1364,9 @@ optdep v1.0.0 p.cargo("tree") .with_stdout_data(str![[r#" foo v0.1.0 ([ROOT]/foo) -└── bar v1.0.0 -[build-dependencies] -└── bar v1.0.0 - └── optdep v1.0.0 +├── bar v1.0.0 +│ └── optdep v1.0.0 +└── optdep v2.0.0 "#]]) .run(); @@ -1379,18 +1374,15 @@ foo v0.1.0 ([ROOT]/foo) p.cargo("tree -p bar") .with_stdout_data(str![[r#" bar v1.0.0 - -bar v1.0.0 └── optdep v1.0.0 "#]]) .run(); - p.cargo("tree -i optdep") + p.cargo("tree -i optdep@1.0.0") .with_stdout_data(str![[r#" optdep v1.0.0 └── bar v1.0.0 - [build-dependencies] └── foo v0.1.0 ([ROOT]/foo) "#]]) @@ -1399,11 +1391,11 @@ optdep v1.0.0 // Check that -d handles duplicates with features. p.cargo("tree -d") .with_stdout_data(str![[r#" -bar v1.0.0 -└── foo v0.1.0 ([ROOT]/foo) +optdep v1.0.0 +└── bar v1.0.0 + └── foo v0.1.0 ([ROOT]/foo) -bar v1.0.0 -[build-dependencies] +optdep v2.0.0 └── foo v0.1.0 ([ROOT]/foo) "#]])