Skip to content

Commit 6158805

Browse files
committed
rustup: translate-libs: Key artifacts by src_path
cargo changed the format of package_id in JSON messages in rust-lang/cargo#13311, but didn't change the format in --unit-graph, so now they don't match. Use src_path as the key for artifact_outputs instead. build-script-executed doesn't have src_path, but we can look it up based on package_id once we have the artifact output.
1 parent 3c8fdfe commit 6158805

File tree

1 file changed

+8
-6
lines changed

1 file changed

+8
-6
lines changed

src/bin/mir-json-translate-libs.rs

Lines changed: 8 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -445,7 +445,7 @@ fn main() {
445445
.iter()
446446
.all(|t| t != "bin" && t != "proc-macro")
447447
{
448-
artifact_outputs.insert(art.package_id.clone(), art);
448+
artifact_outputs.insert(art.target.src_path.clone(), art);
449449
}
450450
}
451451
Message::BuildScriptExecuted(bs) => {
@@ -498,11 +498,13 @@ fn main() {
498498
} else if unit.target.crate_types.iter().any(|t| t == "bin") {
499499
CustomTarget::FinalBin
500500
} else {
501-
let artifact =
502-
artifact_outputs.get(&unit.pkg_id).unwrap_or_else(|| {
501+
let artifact = artifact_outputs
502+
.get(&unit.target.src_path)
503+
.unwrap_or_else(|| {
503504
panic!(
504-
"library {} should have a compiler artifact",
505-
unit.pkg_id
505+
"library {} (src_path {}) \
506+
should have a compiler artifact",
507+
unit.pkg_id, unit.target.src_path
506508
)
507509
});
508510
// Compute the patched source file path by finding the original
@@ -524,7 +526,7 @@ fn main() {
524526
.iter()
525527
.collect();
526528
let (linked_libs, linked_paths, cfgs, env) =
527-
match build_script_outputs.remove(&unit.pkg_id) {
529+
match build_script_outputs.remove(&artifact.package_id) {
528530
Some(bs) => {
529531
(bs.linked_libs, bs.linked_paths, bs.cfgs, bs.env)
530532
}

0 commit comments

Comments
 (0)