Skip to content

Commit a9f163e

Browse files
committed
Keep track of namespaced-features flag in Summary objects
For now, all Summaries from a registry have it set to false.
1 parent 797d453 commit a9f163e

File tree

4 files changed

+19
-6
lines changed

4 files changed

+19
-6
lines changed

src/cargo/core/summary.rs

Lines changed: 6 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -26,6 +26,7 @@ struct Inner {
2626
features: FeatureMap,
2727
checksum: Option<String>,
2828
links: Option<InternedString>,
29+
namespaced_features: bool,
2930
}
3031

3132
impl Summary {
@@ -34,6 +35,7 @@ impl Summary {
3435
dependencies: Vec<Dependency>,
3536
features: BTreeMap<String, Vec<String>>,
3637
links: Option<String>,
38+
namespaced_features: bool,
3739
) -> CargoResult<Summary> {
3840
for dep in dependencies.iter() {
3941
if features.get(&*dep.name()).is_some() {
@@ -58,6 +60,7 @@ impl Summary {
5860
features: feature_map,
5961
checksum: None,
6062
links: links.map(|l| InternedString::new(&l)),
63+
namespaced_features,
6164
}),
6265
})
6366
}
@@ -86,6 +89,9 @@ impl Summary {
8689
pub fn links(&self) -> Option<InternedString> {
8790
self.inner.links
8891
}
92+
pub fn namespaced_features(&self) -> bool {
93+
self.inner.namespaced_features
94+
}
8995

9096
pub fn override_id(mut self, id: PackageId) -> Summary {
9197
Rc::make_mut(&mut self.inner).package_id = id;

src/cargo/sources/registry/index.rs

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -153,7 +153,7 @@ impl<'cfg> RegistryIndex<'cfg> {
153153
let deps = deps.into_iter()
154154
.map(|dep| dep.into_dep(&self.source_id))
155155
.collect::<CargoResult<Vec<_>>>()?;
156-
let summary = Summary::new(pkgid, deps, features, links)?;
156+
let summary = Summary::new(pkgid, deps, features, links, false)?;
157157
let summary = summary.set_checksum(cksum.clone());
158158
if self.hashes.contains_key(&name[..]) {
159159
self.hashes.get_mut(&name[..]).unwrap().insert(vers, cksum);

src/cargo/util/toml/mod.rs

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -845,6 +845,7 @@ impl TomlManifest {
845845
deps,
846846
me.features.clone().unwrap_or_else(BTreeMap::new),
847847
project.links.clone(),
848+
project.namespaced_features.unwrap_or(false),
848849
)?;
849850
let metadata = ManifestMetadata {
850851
description: project.description.clone(),

tests/testsuite/resolve.rs

Lines changed: 11 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -44,7 +44,7 @@ fn resolve_with_config(
4444
}
4545
}
4646
let mut registry = MyRegistry(registry);
47-
let summary = Summary::new(pkg.clone(), deps, BTreeMap::new(), None).unwrap();
47+
let summary = Summary::new(pkg.clone(), deps, BTreeMap::new(), None, false).unwrap();
4848
let method = Method::Everything;
4949
let resolve = resolver::resolve(
5050
&[(summary, method)],
@@ -106,13 +106,13 @@ macro_rules! pkg {
106106
let pkgid = $pkgid.to_pkgid();
107107
let link = if pkgid.name().ends_with("-sys") {Some(pkgid.name().to_string())} else {None};
108108

109-
Summary::new(pkgid, d, BTreeMap::new(), link).unwrap()
109+
Summary::new(pkgid, d, BTreeMap::new(), link, false).unwrap()
110110
});
111111

112112
($pkgid:expr) => ({
113113
let pkgid = $pkgid.to_pkgid();
114114
let link = if pkgid.name().ends_with("-sys") {Some(pkgid.name().to_string())} else {None};
115-
Summary::new(pkgid, Vec::new(), BTreeMap::new(), link).unwrap()
115+
Summary::new(pkgid, Vec::new(), BTreeMap::new(), link, false).unwrap()
116116
})
117117
}
118118

@@ -127,7 +127,7 @@ fn pkg(name: &str) -> Summary {
127127
} else {
128128
None
129129
};
130-
Summary::new(pkg_id(name), Vec::new(), BTreeMap::new(), link).unwrap()
130+
Summary::new(pkg_id(name), Vec::new(), BTreeMap::new(), link, false).unwrap()
131131
}
132132

133133
fn pkg_id(name: &str) -> PackageId {
@@ -148,7 +148,13 @@ fn pkg_loc(name: &str, loc: &str) -> Summary {
148148
} else {
149149
None
150150
};
151-
Summary::new(pkg_id_loc(name, loc), Vec::new(), BTreeMap::new(), link).unwrap()
151+
Summary::new(
152+
pkg_id_loc(name, loc),
153+
Vec::new(),
154+
BTreeMap::new(),
155+
link,
156+
false,
157+
).unwrap()
152158
}
153159

154160
fn dep(name: &str) -> Dependency {

0 commit comments

Comments
 (0)