Skip to content

Commit

Permalink
fix(add): strip feature dep on summary
Browse files Browse the repository at this point in the history
  • Loading branch information
baby230211 committed Mar 12, 2024
1 parent f51df0e commit a644b12
Showing 1 changed file with 23 additions and 2 deletions.
25 changes: 23 additions & 2 deletions src/cargo/util/toml/mod.rs
Original file line number Diff line number Diff line change
Expand Up @@ -987,18 +987,39 @@ pub fn to_real_manifest(
.transpose()?
.unwrap_or_default();
let empty_features = BTreeMap::new();
let deps_map = deps
.iter()
.filter(|dep| dep.is_transitive() || dep.specified_req())
.map(|dep| (dep.name_in_toml(), dep))
.collect::<BTreeMap<InternedString, &Dependency>>();

let summary = Summary::new(
pkgid,
deps,
deps.clone(),
&me.features
.as_ref()
.unwrap_or(&empty_features)
.iter()
.map(|(k, v)| {
(
InternedString::new(k),
v.iter().map(InternedString::from).collect(),
v.iter()
.filter(|feature_dep| {
let feature_value = FeatureValue::new(InternedString::new(feature_dep));
match feature_value {
FeatureValue::Dep { dep_name }
| FeatureValue::DepFeature { dep_name, .. } => {
if let Some(dep) = deps_map.get(&dep_name) {
dep.is_transitive() || dep.specified_req()
} else {
true
}
}
_ => true,
}
})
.map(InternedString::from)
.collect(),
)
})
.collect(),
Expand Down

0 comments on commit a644b12

Please sign in to comment.