]> git.lizzy.rs Git - rust.git/blobdiff - src/librustc_back/svh.rs
Compute a salt from arguments passed via -Cmetadata.
[rust.git] / src / librustc_back / svh.rs
index 3507a119e5455ebbf12dc79509b01b063001b170..ec607314f45c0f35e9edd146b6ea994a8486aea7 100644 (file)
@@ -66,7 +66,7 @@ pub fn as_str<'a>(&'a self) -> &'a str {
         &self.hash
     }
 
-    pub fn calculate(metadata: &Vec<String>, krate: &hir::Crate) -> Svh {
+    pub fn calculate(crate_disambiguator: &str, krate: &hir::Crate) -> Svh {
         // FIXME (#14132): This is better than it used to be, but it still not
         // ideal. We now attempt to hash only the relevant portions of the
         // Crate AST as well as the top-level crate attributes. (However,
@@ -78,9 +78,9 @@ pub fn calculate(metadata: &Vec<String>, krate: &hir::Crate) -> Svh {
         //        avoid collisions.
         let mut state = SipHasher::new();
 
-        for data in metadata {
-            data.hash(&mut state);
-        }
+        "crate_disambiguator".hash(&mut state);
+        crate_disambiguator.len().hash(&mut state);
+        crate_disambiguator.hash(&mut state);
 
         {
             let mut visit = svh_visitor::make(&mut state, krate);