mirror of
https://github.com/rust-lang/rust-analyzer.git
synced 2025-09-27 04:19:13 +00:00
Duplicate dependencies that have multiple DepKinds
This commit is contained in:
parent
01f8d40c5c
commit
518d39cd2f
1 changed files with 23 additions and 17 deletions
|
@ -121,7 +121,7 @@ pub struct PackageDependency {
|
||||||
pub kind: DepKind,
|
pub kind: DepKind,
|
||||||
}
|
}
|
||||||
|
|
||||||
#[derive(Debug, Clone, Eq, PartialEq)]
|
#[derive(Debug, Clone, Eq, PartialEq, PartialOrd, Ord)]
|
||||||
pub enum DepKind {
|
pub enum DepKind {
|
||||||
/// Available to the library, binary, and dev targets in the package (but not the build script).
|
/// Available to the library, binary, and dev targets in the package (but not the build script).
|
||||||
Normal,
|
Normal,
|
||||||
|
@ -132,17 +132,23 @@ pub enum DepKind {
|
||||||
}
|
}
|
||||||
|
|
||||||
impl DepKind {
|
impl DepKind {
|
||||||
fn new(list: &[cargo_metadata::DepKindInfo]) -> Self {
|
fn iter(list: &[cargo_metadata::DepKindInfo]) -> impl Iterator<Item = Self> + '_ {
|
||||||
|
let mut dep_kinds = Vec::new();
|
||||||
|
if list.is_empty() {
|
||||||
|
dep_kinds.push(Self::Normal);
|
||||||
|
}
|
||||||
for info in list {
|
for info in list {
|
||||||
match info.kind {
|
let kind = match info.kind {
|
||||||
cargo_metadata::DependencyKind::Normal => return Self::Normal,
|
cargo_metadata::DependencyKind::Normal => Self::Normal,
|
||||||
cargo_metadata::DependencyKind::Development => return Self::Dev,
|
cargo_metadata::DependencyKind::Development => Self::Dev,
|
||||||
cargo_metadata::DependencyKind::Build => return Self::Build,
|
cargo_metadata::DependencyKind::Build => Self::Build,
|
||||||
cargo_metadata::DependencyKind::Unknown => continue,
|
cargo_metadata::DependencyKind::Unknown => continue,
|
||||||
|
};
|
||||||
|
dep_kinds.push(kind);
|
||||||
}
|
}
|
||||||
}
|
dep_kinds.sort_unstable();
|
||||||
|
dep_kinds.dedup();
|
||||||
Self::Normal
|
dep_kinds.into_iter()
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -317,7 +323,11 @@ impl CargoWorkspace {
|
||||||
}
|
}
|
||||||
};
|
};
|
||||||
node.deps.sort_by(|a, b| a.pkg.cmp(&b.pkg));
|
node.deps.sort_by(|a, b| a.pkg.cmp(&b.pkg));
|
||||||
for dep_node in node.deps {
|
for (dep_node, kind) in node
|
||||||
|
.deps
|
||||||
|
.iter()
|
||||||
|
.flat_map(|dep| DepKind::iter(&dep.dep_kinds).map(move |kind| (dep, kind)))
|
||||||
|
{
|
||||||
let pkg = match pkg_by_id.get(&dep_node.pkg) {
|
let pkg = match pkg_by_id.get(&dep_node.pkg) {
|
||||||
Some(&pkg) => pkg,
|
Some(&pkg) => pkg,
|
||||||
None => {
|
None => {
|
||||||
|
@ -328,11 +338,7 @@ impl CargoWorkspace {
|
||||||
continue;
|
continue;
|
||||||
}
|
}
|
||||||
};
|
};
|
||||||
let dep = PackageDependency {
|
let dep = PackageDependency { name: dep_node.name.clone(), pkg, kind };
|
||||||
name: dep_node.name,
|
|
||||||
pkg,
|
|
||||||
kind: DepKind::new(&dep_node.dep_kinds),
|
|
||||||
};
|
|
||||||
packages[source].dependencies.push(dep);
|
packages[source].dependencies.push(dep);
|
||||||
}
|
}
|
||||||
packages[source].active_features.extend(node.features);
|
packages[source].active_features.extend(node.features);
|
||||||
|
|
Loading…
Add table
Add a link
Reference in a new issue