Keep track of namespaced-features flag in Summary objects
authorDirkjan Ochtman <dirkjan@ochtman.nl>
Mon, 2 Oct 2017 09:00:18 +0000 (11:00 +0200)
committerDirkjan Ochtman <dirkjan@ochtman.nl>
Sat, 28 Apr 2018 11:41:18 +0000 (13:41 +0200)
For now, all Summaries from a registry have it set to false.

src/cargo/core/summary.rs
src/cargo/sources/registry/index.rs
src/cargo/util/toml/mod.rs
tests/testsuite/resolve.rs

index d51db6b889891b776777548ef14e862ac152edf5..cfe1407edd9a6f66218921b298464ebf4899ac93 100644 (file)
@@ -26,6 +26,7 @@ struct Inner {
     features: FeatureMap,
     checksum: Option<String>,
     links: Option<InternedString>,
+    namespaced_features: bool,
 }
 
 impl Summary {
@@ -34,6 +35,7 @@ impl Summary {
         dependencies: Vec<Dependency>,
         features: BTreeMap<String, Vec<String>>,
         links: Option<String>,
+        namespaced_features: bool,
     ) -> CargoResult<Summary> {
         for dep in dependencies.iter() {
             if features.get(&*dep.name()).is_some() {
@@ -58,6 +60,7 @@ impl Summary {
                 features: feature_map,
                 checksum: None,
                 links: links.map(|l| InternedString::new(&l)),
+                namespaced_features,
             }),
         })
     }
@@ -86,6 +89,9 @@ impl Summary {
     pub fn links(&self) -> Option<InternedString> {
         self.inner.links
     }
+    pub fn namespaced_features(&self) -> bool {
+        self.inner.namespaced_features
+    }
 
     pub fn override_id(mut self, id: PackageId) -> Summary {
         Rc::make_mut(&mut self.inner).package_id = id;
index f201250c09faedf161bd18f90a2e2ad8b78ffb35..a8e887d96165d3b58bd72c431eea71971cea4a52 100644 (file)
@@ -153,7 +153,7 @@ impl<'cfg> RegistryIndex<'cfg> {
         let deps = deps.into_iter()
             .map(|dep| dep.into_dep(&self.source_id))
             .collect::<CargoResult<Vec<_>>>()?;
-        let summary = Summary::new(pkgid, deps, features, links)?;
+        let summary = Summary::new(pkgid, deps, features, links, false)?;
         let summary = summary.set_checksum(cksum.clone());
         if self.hashes.contains_key(&name[..]) {
             self.hashes.get_mut(&name[..]).unwrap().insert(vers, cksum);
index da390b4a6fb69b8f685848ecee611386fd1b99e6..5ef05ad009b5b0ed53213ebc21527818d7adbcaa 100644 (file)
@@ -845,6 +845,7 @@ impl TomlManifest {
             deps,
             me.features.clone().unwrap_or_else(BTreeMap::new),
             project.links.clone(),
+            project.namespaced_features.unwrap_or(false),
         )?;
         let metadata = ManifestMetadata {
             description: project.description.clone(),
index a8bf3545b25343ab23c4f6259fc1e79b1502189a..e6377a5418af577e9862953f0638a3e3b653166a 100644 (file)
@@ -44,7 +44,7 @@ fn resolve_with_config(
         }
     }
     let mut registry = MyRegistry(registry);
-    let summary = Summary::new(pkg.clone(), deps, BTreeMap::new(), None).unwrap();
+    let summary = Summary::new(pkg.clone(), deps, BTreeMap::new(), None, false).unwrap();
     let method = Method::Everything;
     let resolve = resolver::resolve(
         &[(summary, method)],
@@ -106,13 +106,13 @@ macro_rules! pkg {
         let pkgid = $pkgid.to_pkgid();
         let link = if pkgid.name().ends_with("-sys") {Some(pkgid.name().to_string())} else {None};
 
-        Summary::new(pkgid, d, BTreeMap::new(), link).unwrap()
+        Summary::new(pkgid, d, BTreeMap::new(), link, false).unwrap()
     });
 
     ($pkgid:expr) => ({
         let pkgid = $pkgid.to_pkgid();
         let link = if pkgid.name().ends_with("-sys") {Some(pkgid.name().to_string())} else {None};
-        Summary::new(pkgid, Vec::new(), BTreeMap::new(), link).unwrap()
+        Summary::new(pkgid, Vec::new(), BTreeMap::new(), link, false).unwrap()
     })
 }
 
@@ -127,7 +127,7 @@ fn pkg(name: &str) -> Summary {
     } else {
         None
     };
-    Summary::new(pkg_id(name), Vec::new(), BTreeMap::new(), link).unwrap()
+    Summary::new(pkg_id(name), Vec::new(), BTreeMap::new(), link, false).unwrap()
 }
 
 fn pkg_id(name: &str) -> PackageId {
@@ -148,7 +148,13 @@ fn pkg_loc(name: &str, loc: &str) -> Summary {
     } else {
         None
     };
-    Summary::new(pkg_id_loc(name, loc), Vec::new(), BTreeMap::new(), link).unwrap()
+    Summary::new(
+        pkg_id_loc(name, loc),
+        Vec::new(),
+        BTreeMap::new(),
+        link,
+        false,
+    ).unwrap()
 }
 
 fn dep(name: &str) -> Dependency {