Skip to content

Commit

Permalink
format and call merge_compile_kind inside collect_used_deps
Browse files Browse the repository at this point in the history
  • Loading branch information
fee1-dead committed Jun 6, 2023
1 parent e4ce6b8 commit 2273009
Show file tree
Hide file tree
Showing 3 changed files with 20 additions and 7 deletions.
20 changes: 16 additions & 4 deletions src/cargo/core/package.rs
Original file line number Diff line number Diff line change
Expand Up @@ -494,7 +494,7 @@ impl<'cfg> PackageSet<'cfg> {
root_ids: &[PackageId],
has_dev_units: HasDevUnits,
requested_kinds: &[CompileKind],
target_data: &RustcTargetData<'cfg>,
target_data: &mut RustcTargetData<'cfg>,
force_all_targets: ForceAllTargets,
) -> CargoResult<()> {
fn collect_used_deps(
Expand All @@ -503,7 +503,7 @@ impl<'cfg> PackageSet<'cfg> {
pkg_id: PackageId,
has_dev_units: HasDevUnits,
requested_kinds: &[CompileKind],
target_data: &RustcTargetData<'_>,
target_data: &mut RustcTargetData<'_>,
force_all_targets: ForceAllTargets,
additional_kinds: Vec<CompileKind>,
) -> CargoResult<()> {
Expand All @@ -515,11 +515,23 @@ impl<'cfg> PackageSet<'cfg> {
resolve,
has_dev_units,
requested_kinds,
target_data,
&*target_data,
force_all_targets,
&additional_kinds,
);
for (pkg_id, _dep, additional_kinds) in filtered_deps {

let deps = filtered_deps
.map(|(pkg_id, _dep, additional_kinds)| (pkg_id, additional_kinds))
.collect::<Vec<_>>();

for (pkg_id, additional_kinds) in deps {
// The dependency can specify additional targets through artifact dependencies.
// We need to run `rustc` to query the target specific configuration before we look
// at this dependency's dependencies.
for kind in &additional_kinds {
target_data.merge_compile_kind(*kind)?;
}

collect_used_deps(
used,
resolve,
Expand Down
2 changes: 1 addition & 1 deletion src/cargo/ops/resolve.rs
Original file line number Diff line number Diff line change
Expand Up @@ -198,7 +198,7 @@ pub fn resolve_ws_with_opts<'cfg>(
&member_ids,
has_dev_units,
requested_targets,
&*target_data,
&mut *target_data,
force_all_targets,
)?;

Expand Down
5 changes: 3 additions & 2 deletions tests/testsuite/artifact_dep.rs
Original file line number Diff line number Diff line change
Expand Up @@ -2905,9 +2905,10 @@ fn check_transitive_artifact_dependency_with_different_target() {
.masquerade_as_nightly_cargo(&["bindeps"])
.with_stderr_contains(
"error: failed to run `rustc` to learn about target-specific information",
).with_stderr_contains(
)
.with_stderr_contains(
"[..] error: Error loading target specification: Could not find specification for \
target \"custom-target\". [..]"
target \"custom-target\". [..]",
)
.with_status(101)
.run();
Expand Down

0 comments on commit 2273009

Please sign in to comment.