From f643b4b5f5a6b6ba3970c17e1395bbfd025b3e99 Mon Sep 17 00:00:00 2001 From: o0Ignition0o Date: Thu, 2 Apr 2020 09:00:44 +0200 Subject: Unique package by name and version. This commit is a fixup of a bug I introduced by using a PackageId to refer to a crate when its name conflicts with a dependency. It turns out the package id currently is `name version path` while cargo expects `name:version` as argument. --- crates/ra_project_model/src/cargo_workspace.rs | 9 +++++---- 1 file changed, 5 insertions(+), 4 deletions(-) (limited to 'crates') diff --git a/crates/ra_project_model/src/cargo_workspace.rs b/crates/ra_project_model/src/cargo_workspace.rs index c1b6e1ddc..b50cda06f 100644 --- a/crates/ra_project_model/src/cargo_workspace.rs +++ b/crates/ra_project_model/src/cargo_workspace.rs @@ -75,7 +75,7 @@ pub type Target = Idx; #[derive(Debug, Clone)] pub struct PackageData { - pub id: String, + pub version: String, pub name: String, pub manifest: PathBuf, pub targets: Vec, @@ -174,14 +174,15 @@ impl CargoWorkspace { let ws_members = &meta.workspace_members; for meta_pkg in meta.packages { - let cargo_metadata::Package { id, edition, name, manifest_path, .. } = meta_pkg; + let cargo_metadata::Package { id, edition, name, manifest_path, version, .. } = + meta_pkg; let is_member = ws_members.contains(&id); let edition = edition .parse::() .with_context(|| format!("Failed to parse edition {}", edition))?; let pkg = packages.alloc(PackageData { name, - id: id.to_string(), + version: version.to_string(), manifest: manifest_path, targets: Vec::new(), is_member, @@ -256,7 +257,7 @@ impl CargoWorkspace { if self.is_unique(&*package.name) { package.name.clone() } else { - package.id.clone() + format!("{}:{}", package.name, package.version) } } -- cgit v1.2.3