Skip to content

Commit c6b4a30

Browse files
committed
crate_universe: move build-script dep to extra_deps
A crate with a build script depends on its own `build_script_build` target. That edge was stored in `common_attrs.deps`, which `Context::workspace_member_deps()` collects to emit crate-hub aliases — so a library crate with a build script got a dead crate-hub alias for itself. Move it to `common_attrs.extra_deps`, which `workspace_member_deps()` does not read, so the self-reference no longer yields an alias. `extra_deps` holds resolved labels, so the edge becomes a relative `:build_script_build` (same target, same package). Fixes #4089.
1 parent fb01b69 commit c6b4a30

2 files changed

Lines changed: 3 additions & 11 deletions

File tree

crate_universe/src/context.rs

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -412,7 +412,6 @@ mod test {
412412
.map(|dep| (&dep.id, context.has_duplicate_workspace_member_dep_by_alias(dep)))
413413
.collect::<Vec<_>>(),
414414
[
415-
(&CrateId::new("child".to_owned(), Version::new(0, 1, 0)), false),
416415
(&CrateId::new("tonic".to_owned(), Version::new(0, 4, 3)), false),
417416
(&CrateId::new("tonic-build".to_owned(), Version::new(0, 4, 2)), false),
418417
],

crate_universe/src/context/crate_context.rs

Lines changed: 3 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,7 @@
11
//! Crate specific information embedded into [crate::context::Context] objects.
22
33
use std::collections::{BTreeMap, BTreeSet};
4+
use std::str::FromStr;
45

56
use camino::Utf8PathBuf;
67
use cargo_metadata::{Node, Package, PackageId};
@@ -496,16 +497,8 @@ impl CrateContext {
496497

497498
let build_script_attrs = if let Some(target) = build_script_target {
498499
// Track the build script dependency
499-
common_attrs.deps.insert(
500-
CrateDependency {
501-
id: current_crate_id,
502-
target: target.crate_name.clone(),
503-
alias: None,
504-
local_path: match source_annotations.get(&annotation.node.id) {
505-
Some(SourceAnnotation::Path { path }) => Some(path.clone()),
506-
_ => None,
507-
},
508-
},
500+
common_attrs.extra_deps.insert(
501+
Label::from_str(&format!(":{}", target.crate_name)).unwrap(),
509502
None,
510503
);
511504

0 commit comments

Comments
 (0)