Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

rustc_metadata: Privatize more things and a couple of other refactorings #66697

Merged
merged 13 commits into from
Nov 29, 2019
Merged
Show file tree
Hide file tree
Changes from 1 commit
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Prev Previous commit
Next Next commit
rustc_metadata: Pass SVH by value
  • Loading branch information
petrochenkov committed Nov 28, 2019
commit e4710ade6d384adc922ee423373739005dbc0330
11 changes: 5 additions & 6 deletions src/librustc_metadata/creader.rs
Original file line number Diff line number Diff line change
Expand Up @@ -191,14 +191,13 @@ impl<'a> CrateLoader<'a> {
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 => {}
}
Expand Down Expand Up @@ -410,10 +409,10 @@ impl<'a> CrateLoader<'a> {
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),
};
Expand Down
10 changes: 5 additions & 5 deletions src/librustc_metadata/locator.rs
Original file line number Diff line number Diff line change
Expand Up @@ -262,8 +262,8 @@ crate struct CrateLocator<'a> {
// 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,
Expand Down Expand Up @@ -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,
Expand Down Expand Up @@ -792,7 +792,7 @@ impl<'a> CrateLocator<'a> {
}

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 {
Expand Down