@@ -390,10 +390,12 @@ impl<'a, 'tcx> CrateLoader<'a, 'tcx> {
390
390
None
391
391
}
392
392
393
- // The `dependency` type is determined by the command line arguments(`--extern`) and
394
- // `private_dep`. However, sometimes the directly dependent crate is not specified by
395
- // `--extern`, in this case, `private-dep` is none during loading. This is equivalent to the
396
- // scenario where the command parameter is set to `public-dependency`
393
+ /// The `dependency` type is determined by the command line arguments(`--extern`) and
394
+ /// `private_dep`.
395
+ ///
396
+ /// Sometimes the directly dependent crate is not specified by `--extern`, in this case,
397
+ /// `private-dep` is none during loading. This is equivalent to the scenario where the
398
+ /// command parameter is set to `public-dependency`
397
399
fn is_private_dep ( & self , name : & str , private_dep : Option < bool > ) -> bool {
398
400
self . sess . opts . externs . get ( name) . map_or ( private_dep. unwrap_or ( false ) , |e| e. is_private_dep )
399
401
&& private_dep. unwrap_or ( true )
@@ -402,7 +404,7 @@ impl<'a, 'tcx> CrateLoader<'a, 'tcx> {
402
404
fn register_crate (
403
405
& mut self ,
404
406
host_lib : Option < Library > ,
405
- root : Option < & CratePaths > ,
407
+ dep_root : Option < & CratePaths > ,
406
408
lib : Library ,
407
409
dep_kind : CrateDepKind ,
408
410
name : Symbol ,
@@ -430,14 +432,14 @@ impl<'a, 'tcx> CrateLoader<'a, 'tcx> {
430
432
// Maintain a reference to the top most crate.
431
433
// Stash paths for top-most crate locally if necessary.
432
434
let crate_paths;
433
- let root = if let Some ( root ) = root {
434
- root
435
+ let dep_root = if let Some ( dep_root ) = dep_root {
436
+ dep_root
435
437
} else {
436
438
crate_paths = CratePaths :: new ( crate_root. name ( ) , source. clone ( ) ) ;
437
439
& crate_paths
438
440
} ;
439
441
440
- let cnum_map = self . resolve_crate_deps ( root , & crate_root, & metadata, cnum, dep_kind) ?;
442
+ let cnum_map = self . resolve_crate_deps ( dep_root , & crate_root, & metadata, cnum, dep_kind) ?;
441
443
442
444
let raw_proc_macros = if crate_root. is_proc_macro_crate ( ) {
443
445
let temp_root;
@@ -559,15 +561,15 @@ impl<'a, 'tcx> CrateLoader<'a, 'tcx> {
559
561
& ' b mut self ,
560
562
name : Symbol ,
561
563
mut dep_kind : CrateDepKind ,
562
- dep : Option < ( & ' b CratePaths , & ' b CrateDep ) > ,
564
+ dep_of : Option < ( & ' b CratePaths , & ' b CrateDep ) > ,
563
565
) -> Result < CrateNum , CrateError > {
564
566
info ! ( "resolving crate `{}`" , name) ;
565
567
if !name. as_str ( ) . is_ascii ( ) {
566
568
return Err ( CrateError :: NonAsciiName ( name) ) ;
567
569
}
568
- let ( root , hash, host_hash, extra_filename, path_kind, private_dep) = match dep {
569
- Some ( ( root , dep) ) => (
570
- Some ( root ) ,
570
+ let ( dep_root , hash, host_hash, extra_filename, path_kind, private_dep) = match dep_of {
571
+ Some ( ( dep_root , dep) ) => (
572
+ Some ( dep_root ) ,
571
573
Some ( dep. hash ) ,
572
574
dep. host_hash ,
573
575
Some ( & dep. extra_filename [ ..] ) ,
@@ -599,7 +601,7 @@ impl<'a, 'tcx> CrateLoader<'a, 'tcx> {
599
601
dep_kind = CrateDepKind :: MacrosOnly ;
600
602
match self . load_proc_macro ( & mut locator, path_kind, host_hash) ? {
601
603
Some ( res) => res,
602
- None => return Err ( locator. into_error ( root . cloned ( ) ) ) ,
604
+ None => return Err ( locator. into_error ( dep_root . cloned ( ) ) ) ,
603
605
}
604
606
}
605
607
}
@@ -623,7 +625,7 @@ impl<'a, 'tcx> CrateLoader<'a, 'tcx> {
623
625
}
624
626
( LoadResult :: Loaded ( library) , host_library) => {
625
627
info ! ( "register newly loaded library for `{}`" , name) ;
626
- self . register_crate ( host_library, root , library, dep_kind, name, private_dep)
628
+ self . register_crate ( host_library, dep_root , library, dep_kind, name, private_dep)
627
629
}
628
630
_ => panic ! ( ) ,
629
631
}
@@ -663,16 +665,20 @@ impl<'a, 'tcx> CrateLoader<'a, 'tcx> {
663
665
} ) )
664
666
}
665
667
666
- // Go through the crate metadata and load any crates that it references
668
+ /// Go through the crate metadata and load any crates that it references.
667
669
fn resolve_crate_deps (
668
670
& mut self ,
669
- root : & CratePaths ,
671
+ dep_root : & CratePaths ,
670
672
crate_root : & CrateRoot ,
671
673
metadata : & MetadataBlob ,
672
674
krate : CrateNum ,
673
675
dep_kind : CrateDepKind ,
674
676
) -> Result < CrateNumMap , CrateError > {
675
- debug ! ( "resolving deps of external crate" ) ;
677
+ debug ! (
678
+ "resolving deps of external crate `{}` with dep root `{}`" ,
679
+ crate_root. name( ) ,
680
+ dep_root. name
681
+ ) ;
676
682
if crate_root. is_proc_macro_crate ( ) {
677
683
return Ok ( CrateNumMap :: new ( ) ) ;
678
684
}
@@ -685,14 +691,17 @@ impl<'a, 'tcx> CrateLoader<'a, 'tcx> {
685
691
crate_num_map. push ( krate) ;
686
692
for dep in deps {
687
693
info ! (
688
- "resolving dep crate {} hash: `{}` extra filename: `{}`" ,
689
- dep. name, dep. hash, dep. extra_filename
694
+ "resolving dep `{}`->`{}` hash: `{}` extra filename: `{}`" ,
695
+ crate_root. name( ) ,
696
+ dep. name,
697
+ dep. hash,
698
+ dep. extra_filename
690
699
) ;
691
700
let dep_kind = match dep_kind {
692
701
CrateDepKind :: MacrosOnly => CrateDepKind :: MacrosOnly ,
693
702
_ => dep. kind ,
694
703
} ;
695
- let cnum = self . maybe_resolve_crate ( dep. name , dep_kind, Some ( ( root , & dep) ) ) ?;
704
+ let cnum = self . maybe_resolve_crate ( dep. name , dep_kind, Some ( ( dep_root , & dep) ) ) ?;
696
705
crate_num_map. push ( cnum) ;
697
706
}
698
707
0 commit comments