Skip to content

Commit 0cd8e9c

Browse files
rukaielchukc
authored andcommitted
Fix panic when running cargo tree on a package with a cross compiled bindep
1 parent b0f2c6b commit 0cd8e9c

File tree

1 file changed

+14
-4
lines changed

1 file changed

+14
-4
lines changed

src/cargo/ops/tree/graph.rs

Lines changed: 14 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -391,10 +391,20 @@ fn add_pkg(
391391
let dep_pkg = graph.package_map[&dep_id];
392392

393393
for dep in deps {
394-
let dep_features_for = if dep.is_build() || dep_pkg.proc_macro() {
395-
FeaturesFor::HostDep
396-
} else {
397-
features_for
394+
let dep_features_for = match dep
395+
.artifact()
396+
.and_then(|artifact| artifact.target())
397+
.and_then(|target| target.to_resolved_compile_target(requested_kind))
398+
{
399+
// Dependency has a `{ …, target = <triple> }`
400+
Some(target) => FeaturesFor::ArtifactDep(target),
401+
None => {
402+
if dep.is_build() || dep_pkg.proc_macro() {
403+
FeaturesFor::HostDep
404+
} else {
405+
features_for
406+
}
407+
}
398408
};
399409
let dep_index = add_pkg(
400410
graph,

0 commit comments

Comments
 (0)