Skip to content

Commit e4710ad

Browse files
committed
rustc_metadata: Pass SVH by value
1 parent 9be526e commit e4710ad

File tree

2 files changed

+10
-11
lines changed

2 files changed

+10
-11
lines changed

src/librustc_metadata/creader.rs

+5-6
Original file line numberDiff line numberDiff line change
@@ -191,14 +191,13 @@ impl<'a> CrateLoader<'a> {
191191
self.cstore
192192
}
193193

194-
fn existing_match(&self, name: Symbol, hash: Option<&Svh>, kind: PathKind)
195-
-> Option<CrateNum> {
194+
fn existing_match(&self, name: Symbol, hash: Option<Svh>, kind: PathKind) -> Option<CrateNum> {
196195
let mut ret = None;
197196
self.cstore.iter_crate_data(|cnum, data| {
198197
if data.name() != name { return }
199198

200199
match hash {
201-
Some(hash) if *hash == data.hash() => { ret = Some(cnum); return }
200+
Some(hash) if hash == data.hash() => { ret = Some(cnum); return }
202201
Some(..) => return,
203202
None => {}
204203
}
@@ -410,10 +409,10 @@ impl<'a> CrateLoader<'a> {
410409
let (root, hash, host_hash, extra_filename, path_kind) = match dep {
411410
Some((root, dep)) => (
412411
Some(root),
413-
Some(&dep.hash),
414-
dep.host_hash.as_ref(),
412+
Some(dep.hash),
413+
dep.host_hash,
415414
Some(&dep.extra_filename[..]),
416-
PathKind::Dependency
415+
PathKind::Dependency,
417416
),
418417
None => (None, None, None, None, PathKind::Crate),
419418
};

src/librustc_metadata/locator.rs

+5-5
Original file line numberDiff line numberDiff line change
@@ -262,8 +262,8 @@ crate struct CrateLocator<'a> {
262262
// Immutable per-search configuration.
263263
crate_name: Symbol,
264264
exact_paths: Vec<PathBuf>,
265-
pub hash: Option<&'a Svh>,
266-
pub host_hash: Option<&'a Svh>,
265+
pub hash: Option<Svh>,
266+
pub host_hash: Option<Svh>,
267267
extra_filename: Option<&'a str>,
268268
pub target: &'a Target,
269269
pub triple: TargetTriple,
@@ -313,8 +313,8 @@ impl<'a> CrateLocator<'a> {
313313
sess: &'a Session,
314314
metadata_loader: &'a dyn MetadataLoader,
315315
crate_name: Symbol,
316-
hash: Option<&'a Svh>,
317-
host_hash: Option<&'a Svh>,
316+
hash: Option<Svh>,
317+
host_hash: Option<Svh>,
318318
extra_filename: Option<&'a str>,
319319
is_host: bool,
320320
path_kind: PathKind,
@@ -792,7 +792,7 @@ impl<'a> CrateLocator<'a> {
792792
}
793793

794794
let hash = root.hash();
795-
if let Some(&expected_hash) = self.hash {
795+
if let Some(expected_hash) = self.hash {
796796
if hash != expected_hash {
797797
info!("Rejecting via hash: expected {} got {}", expected_hash, hash);
798798
self.rejected_via_hash.push(CrateMismatch {

0 commit comments

Comments
 (0)