intern links attribute
authorEh2406 <YeomanYaacov@gmail.com>
Thu, 8 Mar 2018 04:20:17 +0000 (23:20 -0500)
committerEh2406 <YeomanYaacov@gmail.com>
Thu, 8 Mar 2018 04:20:47 +0000 (23:20 -0500)
src/cargo/core/interning.rs
src/cargo/core/resolver/mod.rs
src/cargo/core/summary.rs

index 9fea6503d7fffeb80b8d347d613f6c131e89a806..45dde58105c48dede0c51a65f680958933af7770 100644 (file)
@@ -1,3 +1,4 @@
+use std::fmt;
 use std::sync::RwLock;
 use std::collections::HashSet;
 use std::slice;
@@ -51,6 +52,13 @@ impl Deref for InternedString {
     }
 }
 
+impl fmt::Debug for InternedString {
+    fn fmt(&self, f: &mut fmt::Formatter) -> fmt::Result {
+        let str: &str = &*self;
+        write!(f, "InternedString {{ {} }}", str)
+    }
+}
+
 impl Ord for InternedString {
     fn cmp(&self, other: &InternedString) -> Ordering {
         let str: &str = &*self;
index b6531ec22b6babaf70b9a5cd76bb1145cb286ef3..6edc410c04df1856c721434d02482d696a358b9d 100644 (file)
@@ -734,11 +734,11 @@ impl RemainingCandidates {
         use std::mem::replace;
         for (_, b) in self.remaining.by_ref() {
             if let Some(link) = b.summary.links() {
-                if let Some(a) = links.get(&InternedString::new(link)) {
+                if let Some(a) = links.get(&link) {
                     if a != b.summary.package_id() {
                         self.conflicting_prev_active
                             .entry(a.clone())
-                            .or_insert_with(|| ConflictReason::Links(link.to_owned()));
+                            .or_insert_with(|| ConflictReason::Links(link.to_string()));
                         continue;
                     }
                 }
@@ -1309,9 +1309,9 @@ impl Context {
         if !prev.iter().any(|c| c == summary) {
             self.resolve_graph.push(GraphNode::Add(id.clone()));
             if let Some(link) = summary.links() {
-                ensure!(self.links.insert(InternedString::new(link), id.clone()).is_none(),
+                ensure!(self.links.insert(link, id.clone()).is_none(),
                 "Attempting to resolve a with more then one crate with the links={}. \n\
-                 This will not build as is. Consider rebuilding the .lock file.", link);
+                 This will not build as is. Consider rebuilding the .lock file.", &*link);
             }
             let mut inner: Vec<_> = (**prev).clone();
             inner.push(summary.clone());
index 3613ccb7efc32378c760c95d9daeba7eb30f8cca..4144fde98a84fbc0873be59c36dc8779e693e510 100644 (file)
@@ -4,6 +4,7 @@ use std::rc::Rc;
 
 use semver::Version;
 use core::{Dependency, PackageId, SourceId};
+use core::interning::InternedString;
 
 use util::CargoResult;
 
@@ -22,7 +23,7 @@ struct Inner {
     dependencies: Vec<Dependency>,
     features: BTreeMap<String, Vec<String>>,
     checksum: Option<String>,
-    links: Option<String>,
+    links: Option<InternedString>,
 }
 
 impl Summary {
@@ -71,7 +72,7 @@ impl Summary {
                 dependencies,
                 features,
                 checksum: None,
-                links,
+                links: links.map(|l| InternedString::new(&l)),
             }),
         })
     }
@@ -85,8 +86,8 @@ impl Summary {
     pub fn checksum(&self) -> Option<&str> {
         self.inner.checksum.as_ref().map(|s| &s[..])
     }
-    pub fn links(&self) -> Option<&str> {
-        self.inner.links.as_ref().map(|s| &s[..])
+    pub fn links(&self) -> Option<InternedString> {
+        self.inner.links
     }
 
     pub fn override_id(mut self, id: PackageId) -> Summary {