Skip to content

Commit

Permalink
Rename loader.rs -> locator.rs.
Browse files Browse the repository at this point in the history
  • Loading branch information
jseyfried committed Oct 22, 2016
1 parent 92413c9 commit f3993d1
Show file tree
Hide file tree
Showing 6 changed files with 26 additions and 27 deletions.
5 changes: 2 additions & 3 deletions src/librustc_driver/lib.rs
Expand Up @@ -77,7 +77,7 @@ use rustc::session::config::nightly_options;
use rustc::session::early_error;
use rustc::lint::Lint;
use rustc::lint;
use rustc_metadata::loader;
use rustc_metadata::locator;
use rustc_metadata::cstore::CStore;
use rustc::util::common::time;

Expand Down Expand Up @@ -578,8 +578,7 @@ impl RustcDefaultCalls {
&Input::File(ref ifile) => {
let path = &(*ifile);
let mut v = Vec::new();
loader::list_file_metadata(&sess.target.target, path, &mut v)
.unwrap();
locator::list_file_metadata(&sess.target.target, path, &mut v).unwrap();
println!("{}", String::from_utf8(v).unwrap());
}
&Input::Str { .. } => {
Expand Down
30 changes: 15 additions & 15 deletions src/librustc_metadata/creader.rs
Expand Up @@ -11,7 +11,7 @@
//! Validates all used crates and extern libraries and loads their metadata

use cstore::{self, CStore, CrateSource, MetadataBlob};
use loader::{self, CratePaths};
use locator::{self, CratePaths};
use macro_import;
use schema::CrateRoot;

Expand Down Expand Up @@ -352,7 +352,7 @@ impl<'a> CrateLoader<'a> {
Some(cnum) => LoadResult::Previous(cnum),
None => {
info!("falling back to a load");
let mut load_ctxt = loader::Context {
let mut locate_ctxt = locator::Context {
sess: self.sess,
span: span,
ident: ident,
Expand All @@ -368,9 +368,9 @@ impl<'a> CrateLoader<'a> {
rejected_via_version: vec!(),
should_match_name: true,
};
match self.load(&mut load_ctxt) {
match self.load(&mut locate_ctxt) {
Some(result) => result,
None => load_ctxt.report_load_errs(),
None => locate_ctxt.report_errs(),
}
}
};
Expand All @@ -390,8 +390,8 @@ impl<'a> CrateLoader<'a> {
}
}

fn load(&mut self, loader: &mut loader::Context) -> Option<LoadResult> {
let library = match loader.maybe_load_library_crate() {
fn load(&mut self, locate_ctxt: &mut locator::Context) -> Option<LoadResult> {
let library = match locate_ctxt.maybe_load_library_crate() {
Some(lib) => lib,
None => return None,
};
Expand All @@ -405,11 +405,11 @@ impl<'a> CrateLoader<'a> {
// don't want to match a host crate against an equivalent target one
// already loaded.
let root = library.metadata.get_root();
if loader.triple == self.sess.opts.target_triple {
if locate_ctxt.triple == self.sess.opts.target_triple {
let mut result = LoadResult::Loaded(library);
self.cstore.iter_crate_data(|cnum, data| {
if data.name() == root.name && root.hash == data.hash() {
assert!(loader.hash.is_none());
assert!(locate_ctxt.hash.is_none());
info!("load success, going to previous cnum: {}", cnum);
result = LoadResult::Previous(cnum);
}
Expand Down Expand Up @@ -494,7 +494,7 @@ impl<'a> CrateLoader<'a> {
let mut target_only = false;
let ident = info.ident.clone();
let name = info.name.clone();
let mut load_ctxt = loader::Context {
let mut locate_ctxt = locator::Context {
sess: self.sess,
span: span,
ident: &ident[..],
Expand All @@ -510,7 +510,7 @@ impl<'a> CrateLoader<'a> {
rejected_via_version: vec!(),
should_match_name: true,
};
let library = self.load(&mut load_ctxt).or_else(|| {
let library = self.load(&mut locate_ctxt).or_else(|| {
if !is_cross {
return None
}
Expand All @@ -519,15 +519,15 @@ impl<'a> CrateLoader<'a> {
target_only = true;
should_link = info.should_link;

load_ctxt.target = &self.sess.target.target;
load_ctxt.triple = target_triple;
load_ctxt.filesearch = self.sess.target_filesearch(PathKind::Crate);
locate_ctxt.target = &self.sess.target.target;
locate_ctxt.triple = target_triple;
locate_ctxt.filesearch = self.sess.target_filesearch(PathKind::Crate);

self.load(&mut load_ctxt)
self.load(&mut locate_ctxt)
});
let library = match library {
Some(l) => l,
None => load_ctxt.report_load_errs(),
None => locate_ctxt.report_errs(),
};

let (dylib, metadata) = match library {
Expand Down
4 changes: 2 additions & 2 deletions src/librustc_metadata/cstore.rs
Expand Up @@ -11,7 +11,7 @@
// The crate store - a central repo for information collected about external
// crates and libraries

use loader;
use locator;
use schema;

use rustc::dep_graph::DepGraph;
Expand Down Expand Up @@ -43,7 +43,7 @@ pub type CrateNumMap = IndexVec<CrateNum, CrateNum>;

pub enum MetadataBlob {
Inflated(Bytes),
Archive(loader::ArchiveMetadata),
Archive(locator::ArchiveMetadata),
}

/// Holds information about a syntax_pos::FileMap imported from another crate.
Expand Down
6 changes: 3 additions & 3 deletions src/librustc_metadata/cstore_impl.rs
Expand Up @@ -10,7 +10,7 @@

use cstore;
use encoder;
use loader;
use locator;
use schema;

use rustc::middle::cstore::{InlinedItem, CrateStore, CrateSource, ExternCrate};
Expand Down Expand Up @@ -497,12 +497,12 @@ impl<'tcx> CrateStore<'tcx> for cstore::CStore {

fn metadata_filename(&self) -> &str
{
loader::METADATA_FILENAME
locator::METADATA_FILENAME
}

fn metadata_section_name(&self, target: &Target) -> &str
{
loader::meta_section_name(target)
locator::meta_section_name(target)
}

fn used_crates(&self, prefer: LinkagePreference) -> Vec<(CrateNum, Option<PathBuf>)>
Expand Down
2 changes: 1 addition & 1 deletion src/librustc_metadata/lib.rs
Expand Up @@ -58,7 +58,7 @@ mod schema;

pub mod creader;
pub mod cstore;
pub mod loader;
pub mod locator;
pub mod macro_import;

__build_diagnostic_array! { librustc_metadata, DIAGNOSTICS }
Expand Up @@ -210,7 +210,7 @@
//!
//! That's the general overview of loading crates in the compiler, but it's by
//! no means all of the necessary details. Take a look at the rest of
//! metadata::loader or metadata::creader for all the juicy details!
//! metadata::locator or metadata::creader for all the juicy details!

use cstore::MetadataBlob;
use creader::Library;
Expand Down Expand Up @@ -310,10 +310,10 @@ impl<'a> Context<'a> {
}

pub fn load_library_crate(&mut self) -> Library {
self.find_library_crate().unwrap_or_else(|| self.report_load_errs())
self.find_library_crate().unwrap_or_else(|| self.report_errs())
}

pub fn report_load_errs(&mut self) -> ! {
pub fn report_errs(&mut self) -> ! {
let add = match self.root {
&None => String::new(),
&Some(ref r) => format!(" which `{}` depends on",
Expand Down

0 comments on commit f3993d1

Please sign in to comment.