@@ -394,44 +394,55 @@ impl<'a> CrateLocator<'a> {
394394 // of the crate id (path/name/id).
395395 //
396396 // The goal of this step is to look at as little metadata as possible.
397- self . filesearch . search ( |spf, kind| {
398- let file = match & spf. file_name_str {
399- None => return ,
400- Some ( file) => file,
401- } ;
402- let ( hash, found_kind) = if file. starts_with ( & rlib_prefix) && file. ends_with ( ".rlib" ) {
403- ( & file[ ( rlib_prefix. len ( ) ) ..( file. len ( ) - ".rlib" . len ( ) ) ] , CrateFlavor :: Rlib )
404- } else if file. starts_with ( & rlib_prefix) && file. ends_with ( ".rmeta" ) {
405- ( & file[ ( rlib_prefix. len ( ) ) ..( file. len ( ) - ".rmeta" . len ( ) ) ] , CrateFlavor :: Rmeta )
406- } else if file. starts_with ( & dylib_prefix) && file. ends_with ( & self . target . dll_suffix ) {
407- (
408- & file[ ( dylib_prefix. len ( ) ) ..( file. len ( ) - self . target . dll_suffix . len ( ) ) ] ,
409- CrateFlavor :: Dylib ,
410- )
411- } else {
412- if file. starts_with ( & staticlib_prefix)
413- && file. ends_with ( & self . target . staticlib_suffix )
397+ for search_path in self . filesearch . search_paths ( ) {
398+ debug ! ( "searching {}" , search_path. dir. display( ) ) ;
399+ for spf in search_path. files . iter ( ) {
400+ debug ! ( "testing {}" , spf. path. display( ) ) ;
401+
402+ let file = match & spf. file_name_str {
403+ None => continue ,
404+ Some ( file) => file,
405+ } ;
406+ let ( hash, found_kind) = if file. starts_with ( & rlib_prefix)
407+ && file. ends_with ( ".rlib" )
414408 {
415- staticlibs
416- . push ( CrateMismatch { path : spf. path . clone ( ) , got : "static" . to_string ( ) } ) ;
417- }
418- return ;
419- } ;
409+ ( & file[ ( rlib_prefix. len ( ) ) ..( file. len ( ) - ".rlib" . len ( ) ) ] , CrateFlavor :: Rlib )
410+ } else if file. starts_with ( & rlib_prefix) && file. ends_with ( ".rmeta" ) {
411+ ( & file[ ( rlib_prefix. len ( ) ) ..( file. len ( ) - ".rmeta" . len ( ) ) ] , CrateFlavor :: Rmeta )
412+ } else if file. starts_with ( & dylib_prefix) && file. ends_with ( & self . target . dll_suffix )
413+ {
414+ (
415+ & file[ ( dylib_prefix. len ( ) ) ..( file. len ( ) - self . target . dll_suffix . len ( ) ) ] ,
416+ CrateFlavor :: Dylib ,
417+ )
418+ } else {
419+ if file. starts_with ( & staticlib_prefix)
420+ && file. ends_with ( & self . target . staticlib_suffix )
421+ {
422+ staticlibs. push ( CrateMismatch {
423+ path : spf. path . clone ( ) ,
424+ got : "static" . to_string ( ) ,
425+ } ) ;
426+ }
427+ continue ;
428+ } ;
420429
421- info ! ( "lib candidate: {}" , spf. path. display( ) ) ;
430+ info ! ( "lib candidate: {}" , spf. path. display( ) ) ;
431+
432+ let ( rlibs, rmetas, dylibs) = candidates. entry ( hash. to_string ( ) ) . or_default ( ) ;
433+ let path = fs:: canonicalize ( & spf. path ) . unwrap_or_else ( |_| spf. path . clone ( ) ) ;
434+ if seen_paths. contains ( & path) {
435+ continue ;
436+ } ;
437+ seen_paths. insert ( path. clone ( ) ) ;
438+ match found_kind {
439+ CrateFlavor :: Rlib => rlibs. insert ( path, search_path. kind ) ,
440+ CrateFlavor :: Rmeta => rmetas. insert ( path, search_path. kind ) ,
441+ CrateFlavor :: Dylib => dylibs. insert ( path, search_path. kind ) ,
442+ } ;
443+ }
444+ }
422445
423- let ( rlibs, rmetas, dylibs) = candidates. entry ( hash. to_string ( ) ) . or_default ( ) ;
424- let path = fs:: canonicalize ( & spf. path ) . unwrap_or_else ( |_| spf. path . clone ( ) ) ;
425- if seen_paths. contains ( & path) {
426- return ;
427- } ;
428- seen_paths. insert ( path. clone ( ) ) ;
429- match found_kind {
430- CrateFlavor :: Rlib => rlibs. insert ( path, kind) ,
431- CrateFlavor :: Rmeta => rmetas. insert ( path, kind) ,
432- CrateFlavor :: Dylib => dylibs. insert ( path, kind) ,
433- } ;
434- } ) ;
435446 self . crate_rejections . via_kind . extend ( staticlibs) ;
436447
437448 // We have now collected all known libraries into a set of candidates
0 commit comments