Skip to content

Commit c6bcf60

Browse files
committed
rustc_metadata: locator::Context -> CrateLocator
1 parent 68985c7 commit c6bcf60

File tree

2 files changed

+26
-26
lines changed

2 files changed

+26
-26
lines changed

src/librustc_metadata/creader.rs

Lines changed: 17 additions & 17 deletions
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,7 @@
11
//! Validates all used crates and extern libraries and loads their metadata
22
33
use crate::cstore::{self, CStore};
4-
use crate::locator::{self, CratePaths};
4+
use crate::locator::{CrateLocator, CratePaths};
55
use crate::rmeta::{CrateRoot, CrateDep, MetadataBlob};
66
use rustc_data_structures::sync::{Lock, Once, AtomicCell};
77

@@ -68,13 +68,13 @@ enum LoadResult {
6868
}
6969

7070
enum LoadError<'a> {
71-
LocatorError(locator::Context<'a>),
71+
LocatorError(CrateLocator<'a>),
7272
}
7373

7474
impl<'a> LoadError<'a> {
7575
fn report(self) -> ! {
7676
match self {
77-
LoadError::LocatorError(locate_ctxt) => locate_ctxt.report_errs(),
77+
LoadError::LocatorError(locator) => locator.report_errs(),
7878
}
7979
}
8080
}
@@ -267,15 +267,15 @@ impl<'a> CrateLoader<'a> {
267267

268268
fn load_proc_macro<'b>(
269269
&self,
270-
locate_ctxt: &mut locator::Context<'b>,
270+
locator: &mut CrateLocator<'b>,
271271
path_kind: PathKind,
272272
) -> Option<(LoadResult, Option<Library>)>
273273
where
274274
'a: 'b,
275275
{
276-
// Use a new locator Context so trying to load a proc macro doesn't affect the error
276+
// Use a new crate locator so trying to load a proc macro doesn't affect the error
277277
// message we emit
278-
let mut proc_macro_locator = locate_ctxt.clone();
278+
let mut proc_macro_locator = locator.clone();
279279

280280
// Try to load a proc macro
281281
proc_macro_locator.is_proc_macro = Some(true);
@@ -287,10 +287,10 @@ impl<'a> CrateLoader<'a> {
287287
LoadResult::Previous(cnum) => return Some((LoadResult::Previous(cnum), None)),
288288
LoadResult::Loaded(library) => Some(LoadResult::Loaded(library))
289289
};
290-
locate_ctxt.hash = locate_ctxt.host_hash;
291-
// Use the locate_ctxt when looking for the host proc macro crate, as that is required
290+
locator.hash = locator.host_hash;
291+
// Use the locator when looking for the host proc macro crate, as that is required
292292
// so we want it to affect the error message
293-
(locate_ctxt, result)
293+
(locator, result)
294294
} else {
295295
(&mut proc_macro_locator, None)
296296
};
@@ -350,7 +350,7 @@ impl<'a> CrateLoader<'a> {
350350
(LoadResult::Previous(cnum), None)
351351
} else {
352352
info!("falling back to a load");
353-
let mut locate_ctxt = locator::Context {
353+
let mut locator = CrateLocator {
354354
sess: self.sess,
355355
span,
356356
crate_name: name,
@@ -371,10 +371,10 @@ impl<'a> CrateLoader<'a> {
371371
metadata_loader: self.metadata_loader,
372372
};
373373

374-
self.load(&mut locate_ctxt).map(|r| (r, None)).or_else(|| {
374+
self.load(&mut locator).map(|r| (r, None)).or_else(|| {
375375
dep_kind = DepKind::UnexportedMacrosOnly;
376-
self.load_proc_macro(&mut locate_ctxt, path_kind)
377-
}).ok_or_else(move || LoadError::LocatorError(locate_ctxt))?
376+
self.load_proc_macro(&mut locator, path_kind)
377+
}).ok_or_else(move || LoadError::LocatorError(locator))?
378378
};
379379

380380
match result {
@@ -395,8 +395,8 @@ impl<'a> CrateLoader<'a> {
395395
}
396396
}
397397

398-
fn load(&self, locate_ctxt: &mut locator::Context<'_>) -> Option<LoadResult> {
399-
let library = locate_ctxt.maybe_load_library_crate()?;
398+
fn load(&self, locator: &mut CrateLocator<'_>) -> Option<LoadResult> {
399+
let library = locator.maybe_load_library_crate()?;
400400

401401
// In the case that we're loading a crate, but not matching
402402
// against a hash, we could load a crate which has the same hash
@@ -407,11 +407,11 @@ impl<'a> CrateLoader<'a> {
407407
// don't want to match a host crate against an equivalent target one
408408
// already loaded.
409409
let root = library.metadata.get_root();
410-
if locate_ctxt.triple == self.sess.opts.target_triple {
410+
if locator.triple == self.sess.opts.target_triple {
411411
let mut result = LoadResult::Loaded(library);
412412
self.cstore.iter_crate_data(|cnum, data| {
413413
if data.root.name == root.name && root.hash == data.root.hash {
414-
assert!(locate_ctxt.hash.is_none());
414+
assert!(locator.hash.is_none());
415415
info!("load success, going to previous cnum: {}", cnum);
416416
result = LoadResult::Previous(cnum);
417417
}

src/librustc_metadata/locator.rs

Lines changed: 9 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -254,7 +254,7 @@ crate struct CrateMismatch {
254254
}
255255

256256
#[derive(Clone)]
257-
crate struct Context<'a> {
257+
crate struct CrateLocator<'a> {
258258
pub sess: &'a Session,
259259
pub span: Span,
260260
pub crate_name: Symbol,
@@ -298,7 +298,7 @@ impl fmt::Display for CrateFlavor {
298298
}
299299
}
300300

301-
impl<'a> Context<'a> {
301+
impl<'a> CrateLocator<'a> {
302302
crate fn reset(&mut self) {
303303
self.rejected_via_hash.clear();
304304
self.rejected_via_triple.clear();
@@ -926,7 +926,7 @@ pub fn find_plugin_registrar(
926926
let host_triple = TargetTriple::from_triple(config::host_triple());
927927
let is_cross = target_triple != host_triple;
928928
let mut target_only = false;
929-
let mut locate_ctxt = Context {
929+
let mut locator = CrateLocator {
930930
sess,
931931
span,
932932
crate_name: name,
@@ -947,23 +947,23 @@ pub fn find_plugin_registrar(
947947
metadata_loader,
948948
};
949949

950-
let library = locate_ctxt.maybe_load_library_crate().or_else(|| {
950+
let library = locator.maybe_load_library_crate().or_else(|| {
951951
if !is_cross {
952952
return None
953953
}
954954
// Try loading from target crates. This will abort later if we
955955
// try to load a plugin registrar function,
956956
target_only = true;
957957

958-
locate_ctxt.target = &sess.target.target;
959-
locate_ctxt.triple = target_triple;
960-
locate_ctxt.filesearch = sess.target_filesearch(PathKind::Crate);
958+
locator.target = &sess.target.target;
959+
locator.triple = target_triple;
960+
locator.filesearch = sess.target_filesearch(PathKind::Crate);
961961

962-
locate_ctxt.maybe_load_library_crate()
962+
locator.maybe_load_library_crate()
963963
});
964964
let library = match library {
965965
Some(l) => l,
966-
None => locate_ctxt.report_errs(),
966+
None => locator.report_errs(),
967967
};
968968

969969
if target_only {

0 commit comments

Comments
 (0)