]> git.lizzy.rs Git - rust.git/commitdiff
rustc_metadata: Pass SVH by value
authorVadim Petrochenkov <vadim.petrochenkov@gmail.com>
Sun, 24 Nov 2019 12:29:35 +0000 (15:29 +0300)
committerVadim Petrochenkov <vadim.petrochenkov@gmail.com>
Thu, 28 Nov 2019 17:59:57 +0000 (20:59 +0300)
src/librustc_metadata/creader.rs
src/librustc_metadata/locator.rs

index 3c5468466e4a39ff0084c33b656fd5e7744556b3..22f997ca4e1bb003e6b9edd43edc1e0c5ad9123a 100644 (file)
@@ -191,14 +191,13 @@ pub fn into_cstore(self) -> CStore {
         self.cstore
     }
 
-    fn existing_match(&self, name: Symbol, hash: Option<&Svh>, kind: PathKind)
-                      -> Option<CrateNum> {
+    fn existing_match(&self, name: Symbol, hash: Option<Svh>, kind: PathKind) -> Option<CrateNum> {
         let mut ret = None;
         self.cstore.iter_crate_data(|cnum, data| {
             if data.name() != name { return }
 
             match hash {
-                Some(hash) if *hash == data.hash() => { ret = Some(cnum); return }
+                Some(hash) if hash == data.hash() => { ret = Some(cnum); return }
                 Some(..) => return,
                 None => {}
             }
@@ -410,10 +409,10 @@ fn maybe_resolve_crate<'b>(
         let (root, hash, host_hash, extra_filename, path_kind) = match dep {
             Some((root, dep)) => (
                 Some(root),
-                Some(&dep.hash),
-                dep.host_hash.as_ref(),
+                Some(dep.hash),
+                dep.host_hash,
                 Some(&dep.extra_filename[..]),
-                PathKind::Dependency
+                PathKind::Dependency,
             ),
             None => (None, None, None, None, PathKind::Crate),
         };
index a7a4a96bb5221ca088a78fe7971bb60c37434686..c6fb80eca055ad98cce36d9faa0cbc2028b4c4ff 100644 (file)
@@ -262,8 +262,8 @@ struct CrateMismatch {
     // Immutable per-search configuration.
     crate_name: Symbol,
     exact_paths: Vec<PathBuf>,
-    pub hash: Option<&'a Svh>,
-    pub host_hash: Option<&'a Svh>,
+    pub hash: Option<Svh>,
+    pub host_hash: Option<Svh>,
     extra_filename: Option<&'a str>,
     pub target: &'a Target,
     pub triple: TargetTriple,
@@ -313,8 +313,8 @@ impl<'a> CrateLocator<'a> {
         sess: &'a Session,
         metadata_loader: &'a dyn MetadataLoader,
         crate_name: Symbol,
-        hash: Option<&'a Svh>,
-        host_hash: Option<&'a Svh>,
+        hash: Option<Svh>,
+        host_hash: Option<Svh>,
         extra_filename: Option<&'a str>,
         is_host: bool,
         path_kind: PathKind,
@@ -792,7 +792,7 @@ fn crate_matches(&mut self, metadata: &MetadataBlob, libpath: &Path) -> Option<S
         }
 
         let hash = root.hash();
-        if let Some(&expected_hash) = self.hash {
+        if let Some(expected_hash) = self.hash {
             if hash != expected_hash {
                 info!("Rejecting via hash: expected {} got {}", expected_hash, hash);
                 self.rejected_via_hash.push(CrateMismatch {