11//! Validates all used crates and extern libraries and loads their metadata
22
33use crate :: cstore:: { self , CStore } ;
4- use crate :: locator:: { self , CratePaths } ;
4+ use crate :: locator:: { CrateLocator , CratePaths } ;
55use crate :: rmeta:: { CrateRoot , CrateDep , MetadataBlob } ;
66use rustc_data_structures:: sync:: { Lock , Once , AtomicCell } ;
77
@@ -68,13 +68,13 @@ enum LoadResult {
6868}
6969
7070enum LoadError < ' a > {
71- LocatorError ( locator :: Context < ' a > ) ,
71+ LocatorError ( CrateLocator < ' a > ) ,
7272}
7373
7474impl < ' 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 }
0 commit comments