@@ -371,11 +371,17 @@ impl<'a> CrateLocator<'a> {
371371 extra_prefix : & str ,
372372 seen_paths : & mut FxHashSet < PathBuf > ,
373373 ) -> Result < Option < Library > , CrateError > {
374- // want: crate_name.dir_part() + prefix + crate_name.file_part + "-"
375- let dylib_prefix = format ! ( "{}{}{}" , self . target. dll_prefix, self . crate_name, extra_prefix) ;
376- let rlib_prefix = format ! ( "lib{}{}" , self . crate_name, extra_prefix) ;
374+ let rmeta_prefix = & format ! ( "lib{}{}" , self . crate_name, extra_prefix) ;
375+ let rlib_prefix = rmeta_prefix;
376+ let dylib_prefix =
377+ & format ! ( "{}{}{}" , self . target. dll_prefix, self . crate_name, extra_prefix) ;
377378 let staticlib_prefix =
378- format ! ( "{}{}{}" , self . target. staticlib_prefix, self . crate_name, extra_prefix) ;
379+ & format ! ( "{}{}{}" , self . target. staticlib_prefix, self . crate_name, extra_prefix) ;
380+
381+ let rmeta_suffix = ".rmeta" ;
382+ let rlib_suffix = ".rlib" ;
383+ let dylib_suffix = & self . target . dll_suffix ;
384+ let staticlib_suffix = & self . target . staticlib_suffix ;
379385
380386 let mut candidates: FxHashMap < _ , ( FxHashMap < _ , _ > , FxHashMap < _ , _ > , FxHashMap < _ , _ > ) > =
381387 Default :: default ( ) ;
@@ -399,23 +405,15 @@ impl<'a> CrateLocator<'a> {
399405 for spf in search_path. files . iter ( ) {
400406 debug ! ( "testing {}" , spf. path. display( ) ) ;
401407
402- let file = & spf. file_name_str ;
403- let ( hash, found_kind) = if file. starts_with ( & rlib_prefix)
404- && file. ends_with ( ".rlib" )
405- {
406- ( & file[ ( rlib_prefix. len ( ) ) ..( file. len ( ) - ".rlib" . len ( ) ) ] , CrateFlavor :: Rlib )
407- } else if file. starts_with ( & rlib_prefix) && file. ends_with ( ".rmeta" ) {
408- ( & file[ ( rlib_prefix. len ( ) ) ..( file. len ( ) - ".rmeta" . len ( ) ) ] , CrateFlavor :: Rmeta )
409- } else if file. starts_with ( & dylib_prefix) && file. ends_with ( & self . target . dll_suffix )
410- {
411- (
412- & file[ ( dylib_prefix. len ( ) ) ..( file. len ( ) - self . target . dll_suffix . len ( ) ) ] ,
413- CrateFlavor :: Dylib ,
414- )
408+ let f = & spf. file_name_str ;
409+ let ( hash, kind) = if f. starts_with ( rlib_prefix) && f. ends_with ( rlib_suffix) {
410+ ( & f[ rlib_prefix. len ( ) ..( f. len ( ) - rlib_suffix. len ( ) ) ] , CrateFlavor :: Rlib )
411+ } else if f. starts_with ( rmeta_prefix) && f. ends_with ( rmeta_suffix) {
412+ ( & f[ rmeta_prefix. len ( ) ..( f. len ( ) - rmeta_suffix. len ( ) ) ] , CrateFlavor :: Rmeta )
413+ } else if f. starts_with ( dylib_prefix) && f. ends_with ( dylib_suffix) {
414+ ( & f[ dylib_prefix. len ( ) ..( f. len ( ) - dylib_suffix. len ( ) ) ] , CrateFlavor :: Dylib )
415415 } else {
416- if file. starts_with ( & staticlib_prefix)
417- && file. ends_with ( & self . target . staticlib_suffix )
418- {
416+ if f. starts_with ( staticlib_prefix) && f. ends_with ( staticlib_suffix) {
419417 staticlibs. push ( CrateMismatch {
420418 path : spf. path . clone ( ) ,
421419 got : "static" . to_string ( ) ,
@@ -432,7 +430,7 @@ impl<'a> CrateLocator<'a> {
432430 continue ;
433431 } ;
434432 seen_paths. insert ( path. clone ( ) ) ;
435- match found_kind {
433+ match kind {
436434 CrateFlavor :: Rlib => rlibs. insert ( path, search_path. kind ) ,
437435 CrateFlavor :: Rmeta => rmetas. insert ( path, search_path. kind ) ,
438436 CrateFlavor :: Dylib => dylibs. insert ( path, search_path. kind ) ,
0 commit comments