Skip to content

Commit f643b4b

Browse files
committed
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.
1 parent f696df3 commit f643b4b

File tree

1 file changed

+5
-4
lines changed

1 file changed

+5
-4
lines changed

crates/ra_project_model/src/cargo_workspace.rs

Lines changed: 5 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -75,7 +75,7 @@ pub type Target = Idx<TargetData>;
7575

7676
#[derive(Debug, Clone)]
7777
pub struct PackageData {
78-
pub id: String,
78+
pub version: String,
7979
pub name: String,
8080
pub manifest: PathBuf,
8181
pub targets: Vec<Target>,
@@ -174,14 +174,15 @@ impl CargoWorkspace {
174174
let ws_members = &meta.workspace_members;
175175

176176
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;
178179
let is_member = ws_members.contains(&id);
179180
let edition = edition
180181
.parse::<Edition>()
181182
.with_context(|| format!("Failed to parse edition {}", edition))?;
182183
let pkg = packages.alloc(PackageData {
183184
name,
184-
id: id.to_string(),
185+
version: version.to_string(),
185186
manifest: manifest_path,
186187
targets: Vec::new(),
187188
is_member,
@@ -256,7 +257,7 @@ impl CargoWorkspace {
256257
if self.is_unique(&*package.name) {
257258
package.name.clone()
258259
} else {
259-
package.id.clone()
260+
format!("{}:{}", package.name, package.version)
260261
}
261262
}
262263

0 commit comments

Comments
 (0)