1
1
//! Validates all used crates and extern libraries and loads their metadata
2
2
3
3
use crate :: cstore:: { self , CStore } ;
4
- use crate :: locator:: { self , CratePaths } ;
4
+ use crate :: locator:: { CrateLocator , CratePaths } ;
5
5
use crate :: rmeta:: { CrateRoot , CrateDep , MetadataBlob } ;
6
6
use rustc_data_structures:: sync:: { Lock , Once , AtomicCell } ;
7
7
@@ -68,13 +68,13 @@ enum LoadResult {
68
68
}
69
69
70
70
enum LoadError < ' a > {
71
- LocatorError ( locator :: Context < ' a > ) ,
71
+ LocatorError ( CrateLocator < ' a > ) ,
72
72
}
73
73
74
74
impl < ' a > LoadError < ' a > {
75
75
fn report ( self ) -> ! {
76
76
match self {
77
- LoadError :: LocatorError ( locate_ctxt ) => locate_ctxt . report_errs ( ) ,
77
+ LoadError :: LocatorError ( locator ) => locator . report_errs ( ) ,
78
78
}
79
79
}
80
80
}
@@ -267,15 +267,15 @@ impl<'a> CrateLoader<'a> {
267
267
268
268
fn load_proc_macro < ' b > (
269
269
& self ,
270
- locate_ctxt : & mut locator :: Context < ' b > ,
270
+ locator : & mut CrateLocator < ' b > ,
271
271
path_kind : PathKind ,
272
272
) -> Option < ( LoadResult , Option < Library > ) >
273
273
where
274
274
' a : ' b ,
275
275
{
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
277
277
// message we emit
278
- let mut proc_macro_locator = locate_ctxt . clone ( ) ;
278
+ let mut proc_macro_locator = locator . clone ( ) ;
279
279
280
280
// Try to load a proc macro
281
281
proc_macro_locator. is_proc_macro = Some ( true ) ;
@@ -287,10 +287,10 @@ impl<'a> CrateLoader<'a> {
287
287
LoadResult :: Previous ( cnum) => return Some ( ( LoadResult :: Previous ( cnum) , None ) ) ,
288
288
LoadResult :: Loaded ( library) => Some ( LoadResult :: Loaded ( library) )
289
289
} ;
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
292
292
// so we want it to affect the error message
293
- ( locate_ctxt , result)
293
+ ( locator , result)
294
294
} else {
295
295
( & mut proc_macro_locator, None )
296
296
} ;
@@ -350,7 +350,7 @@ impl<'a> CrateLoader<'a> {
350
350
( LoadResult :: Previous ( cnum) , None )
351
351
} else {
352
352
info ! ( "falling back to a load" ) ;
353
- let mut locate_ctxt = locator :: Context {
353
+ let mut locator = CrateLocator {
354
354
sess : self . sess ,
355
355
span,
356
356
crate_name : name,
@@ -371,10 +371,10 @@ impl<'a> CrateLoader<'a> {
371
371
metadata_loader : self . metadata_loader ,
372
372
} ;
373
373
374
- self . load ( & mut locate_ctxt ) . map ( |r| ( r, None ) ) . or_else ( || {
374
+ self . load ( & mut locator ) . map ( |r| ( r, None ) ) . or_else ( || {
375
375
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 ) ) ?
378
378
} ;
379
379
380
380
match result {
@@ -395,8 +395,8 @@ impl<'a> CrateLoader<'a> {
395
395
}
396
396
}
397
397
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 ( ) ?;
400
400
401
401
// In the case that we're loading a crate, but not matching
402
402
// against a hash, we could load a crate which has the same hash
@@ -407,11 +407,11 @@ impl<'a> CrateLoader<'a> {
407
407
// don't want to match a host crate against an equivalent target one
408
408
// already loaded.
409
409
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 {
411
411
let mut result = LoadResult :: Loaded ( library) ;
412
412
self . cstore . iter_crate_data ( |cnum, data| {
413
413
if data. root . name == root. name && root. hash == data. root . hash {
414
- assert ! ( locate_ctxt . hash. is_none( ) ) ;
414
+ assert ! ( locator . hash. is_none( ) ) ;
415
415
info ! ( "load success, going to previous cnum: {}" , cnum) ;
416
416
result = LoadResult :: Previous ( cnum) ;
417
417
}
0 commit comments