aboutsummaryrefslogtreecommitdiff
path: root/crates
diff options
context:
space:
mode:
authoro0Ignition0o <[email protected]>2020-04-02 08:00:44 +0100
committero0Ignition0o <[email protected]>2020-04-02 08:00:44 +0100
commitf643b4b5f5a6b6ba3970c17e1395bbfd025b3e99 (patch)
tree333298f69acf3ff5091011462b8e736ce8605cc7 /crates
parentf696df379a5dd450b3d89a8c690de5f8d78f6be2 (diff)
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.
Diffstat (limited to 'crates')
-rw-r--r--crates/ra_project_model/src/cargo_workspace.rs9
1 files changed, 5 insertions, 4 deletions
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<TargetData>;
75 75
76#[derive(Debug, Clone)] 76#[derive(Debug, Clone)]
77pub struct PackageData { 77pub struct PackageData {
78 pub id: String, 78 pub version: String,
79 pub name: String, 79 pub name: String,
80 pub manifest: PathBuf, 80 pub manifest: PathBuf,
81 pub targets: Vec<Target>, 81 pub targets: Vec<Target>,
@@ -174,14 +174,15 @@ impl CargoWorkspace {
174 let ws_members = &meta.workspace_members; 174 let ws_members = &meta.workspace_members;
175 175
176 for meta_pkg in meta.packages { 176 for meta_pkg in meta.packages {
177 let cargo_metadata::Package { id, edition, name, manifest_path, .. } = meta_pkg; 177 let cargo_metadata::Package { id, edition, name, manifest_path, version, .. } =
178 meta_pkg;
178 let is_member = ws_members.contains(&id); 179 let is_member = ws_members.contains(&id);
179 let edition = edition 180 let edition = edition
180 .parse::<Edition>() 181 .parse::<Edition>()
181 .with_context(|| format!("Failed to parse edition {}", edition))?; 182 .with_context(|| format!("Failed to parse edition {}", edition))?;
182 let pkg = packages.alloc(PackageData { 183 let pkg = packages.alloc(PackageData {
183 name, 184 name,
184 id: id.to_string(), 185 version: version.to_string(),
185 manifest: manifest_path, 186 manifest: manifest_path,
186 targets: Vec::new(), 187 targets: Vec::new(),
187 is_member, 188 is_member,
@@ -256,7 +257,7 @@ impl CargoWorkspace {
256 if self.is_unique(&*package.name) { 257 if self.is_unique(&*package.name) {
257 package.name.clone() 258 package.name.clone()
258 } else { 259 } else {
259 package.id.clone() 260 format!("{}:{}", package.name, package.version)
260 } 261 }
261 } 262 }
262 263