@@ -218,7 +218,7 @@ use std::ops::Deref;
218218use std:: path:: { Path , PathBuf } ;
219219use std:: { cmp, fmt} ;
220220
221- use rustc_data_structures:: fx:: { FxHashSet , FxIndexMap } ;
221+ use rustc_data_structures:: fx:: { FxHashSet , FxIndexMap , FxIndexSet } ;
222222use rustc_data_structures:: memmap:: Mmap ;
223223use rustc_data_structures:: owned_slice:: { OwnedSlice , slice_owned} ;
224224use rustc_data_structures:: svh:: Svh ;
@@ -401,7 +401,7 @@ impl<'a> CrateLocator<'a> {
401401
402402 let mut candidates: FxIndexMap <
403403 _ ,
404- ( FxIndexMap < _ , _ > , FxIndexMap < _ , _ > , FxIndexMap < _ , _ > , FxIndexMap < _ , _ > ) ,
404+ ( FxIndexSet < _ > , FxIndexSet < _ > , FxIndexSet < _ > , FxIndexSet < _ > ) ,
405405 > = Default :: default ( ) ;
406406
407407 // First, find all possible candidate rlibs and dylibs purely based on
@@ -460,10 +460,10 @@ impl<'a> CrateLocator<'a> {
460460 // filesystem code should not care, but this is nicer for diagnostics.
461461 let path = spf. path . to_path_buf ( ) ;
462462 match kind {
463- CrateFlavor :: Rlib => rlibs. insert ( path, search_path . kind ) ,
464- CrateFlavor :: Rmeta => rmetas. insert ( path, search_path . kind ) ,
465- CrateFlavor :: Dylib => dylibs. insert ( path, search_path . kind ) ,
466- CrateFlavor :: SDylib => interfaces. insert ( path, search_path . kind ) ,
463+ CrateFlavor :: Rlib => rlibs. insert ( path) ,
464+ CrateFlavor :: Rmeta => rmetas. insert ( path) ,
465+ CrateFlavor :: Dylib => dylibs. insert ( path) ,
466+ CrateFlavor :: SDylib => interfaces. insert ( path) ,
467467 } ;
468468 }
469469 }
@@ -524,10 +524,10 @@ impl<'a> CrateLocator<'a> {
524524 fn extract_lib (
525525 & self ,
526526 crate_rejections : & mut CrateRejections ,
527- rlibs : FxIndexMap < PathBuf , PathKind > ,
528- rmetas : FxIndexMap < PathBuf , PathKind > ,
529- dylibs : FxIndexMap < PathBuf , PathKind > ,
530- interfaces : FxIndexMap < PathBuf , PathKind > ,
527+ rlibs : FxIndexSet < PathBuf > ,
528+ rmetas : FxIndexSet < PathBuf > ,
529+ dylibs : FxIndexSet < PathBuf > ,
530+ interfaces : FxIndexSet < PathBuf > ,
531531 ) -> Result < Option < ( Svh , Library ) > , CrateError > {
532532 let mut slot = None ;
533533 // Order here matters, rmeta should come first.
@@ -575,10 +575,10 @@ impl<'a> CrateLocator<'a> {
575575 fn extract_one (
576576 & self ,
577577 crate_rejections : & mut CrateRejections ,
578- m : FxIndexMap < PathBuf , PathKind > ,
578+ m : FxIndexSet < PathBuf > ,
579579 flavor : CrateFlavor ,
580580 slot : & mut Option < ( Svh , MetadataBlob , PathBuf , CrateFlavor ) > ,
581- ) -> Result < Option < ( PathBuf , PathKind ) > , CrateError > {
581+ ) -> Result < Option < PathBuf > , CrateError > {
582582 // If we are producing an rlib, and we've already loaded metadata, then
583583 // we should not attempt to discover further crate sources (unless we're
584584 // locating a proc macro; exact logic is in needs_crate_flavor). This means
@@ -594,9 +594,9 @@ impl<'a> CrateLocator<'a> {
594594 }
595595 }
596596
597- let mut ret: Option < ( PathBuf , PathKind ) > = None ;
597+ let mut ret: Option < PathBuf > = None ;
598598 let mut err_data: Option < Vec < PathBuf > > = None ;
599- for ( lib, kind ) in m {
599+ for lib in m {
600600 info ! ( "{} reading metadata from: {}" , flavor, lib. display( ) ) ;
601601 if flavor == CrateFlavor :: Rmeta && lib. metadata ( ) . is_ok_and ( |m| m. len ( ) == 0 ) {
602602 // Empty files will cause get_metadata_section to fail. Rmeta
@@ -640,7 +640,7 @@ impl<'a> CrateLocator<'a> {
640640 info ! ( "no metadata found: {}" , err) ;
641641 // Metadata was loaded from interface file earlier.
642642 if let Some ( ( .., CrateFlavor :: SDylib ) ) = slot {
643- ret = Some ( ( lib, kind ) ) ;
643+ ret = Some ( lib) ;
644644 continue ;
645645 }
646646 // The file was present and created by the same compiler version, but we
@@ -689,7 +689,7 @@ impl<'a> CrateLocator<'a> {
689689 // As a result, we favor the sysroot crate here. Note that the
690690 // candidates are all canonicalized, so we canonicalize the sysroot
691691 // as well.
692- if let Some ( ( prev, _ ) ) = & ret {
692+ if let Some ( prev) = & ret {
693693 let sysroot = self . sysroot ;
694694 let sysroot = try_canonicalize ( sysroot) . unwrap_or_else ( |_| sysroot. to_path_buf ( ) ) ;
695695 if prev. starts_with ( & sysroot) {
@@ -714,7 +714,7 @@ impl<'a> CrateLocator<'a> {
714714 } else {
715715 * slot = Some ( ( hash, metadata, lib. clone ( ) , flavor) ) ;
716716 }
717- ret = Some ( ( lib, kind ) ) ;
717+ ret = Some ( lib) ;
718718 }
719719
720720 if let Some ( candidates) = err_data {
@@ -774,10 +774,10 @@ impl<'a> CrateLocator<'a> {
774774 // First, filter out all libraries that look suspicious. We only accept
775775 // files which actually exist that have the correct naming scheme for
776776 // rlibs/dylibs.
777- let mut rlibs = FxIndexMap :: default ( ) ;
778- let mut rmetas = FxIndexMap :: default ( ) ;
779- let mut dylibs = FxIndexMap :: default ( ) ;
780- let mut sdylib_interfaces = FxIndexMap :: default ( ) ;
777+ let mut rlibs = FxIndexSet :: default ( ) ;
778+ let mut rmetas = FxIndexSet :: default ( ) ;
779+ let mut dylibs = FxIndexSet :: default ( ) ;
780+ let mut sdylib_interfaces = FxIndexSet :: default ( ) ;
781781 for loc in & self . exact_paths {
782782 let loc_canon = loc. canonicalized ( ) ;
783783 let loc_orig = loc. original ( ) ;
@@ -798,21 +798,21 @@ impl<'a> CrateLocator<'a> {
798798 } ;
799799 if file. starts_with ( "lib" ) {
800800 if file. ends_with ( ".rlib" ) {
801- rlibs. insert ( loc_canon. clone ( ) , PathKind :: ExternFlag ) ;
801+ rlibs. insert ( loc_canon. clone ( ) ) ;
802802 continue ;
803803 }
804804 if file. ends_with ( ".rmeta" ) {
805- rmetas. insert ( loc_canon. clone ( ) , PathKind :: ExternFlag ) ;
805+ rmetas. insert ( loc_canon. clone ( ) ) ;
806806 continue ;
807807 }
808808 if file. ends_with ( ".rs" ) {
809- sdylib_interfaces. insert ( loc_canon. clone ( ) , PathKind :: ExternFlag ) ;
809+ sdylib_interfaces. insert ( loc_canon. clone ( ) ) ;
810810 }
811811 }
812812 let dll_prefix = self . target . dll_prefix . as_ref ( ) ;
813813 let dll_suffix = self . target . dll_suffix . as_ref ( ) ;
814814 if file. starts_with ( dll_prefix) && file. ends_with ( dll_suffix) {
815- dylibs. insert ( loc_canon. clone ( ) , PathKind :: ExternFlag ) ;
815+ dylibs. insert ( loc_canon. clone ( ) ) ;
816816 continue ;
817817 }
818818 crate_rejections
0 commit comments