@@ -728,37 +728,25 @@ impl<'a> CrateLocator<'a> {
728728 let Some ( file) = loc_orig. file_name ( ) . and_then ( |s| s. to_str ( ) ) else {
729729 return Err ( CrateError :: ExternLocationNotFile ( self . crate_name , loc_orig. clone ( ) ) ) ;
730730 } ;
731- // FnMut cannot return reference to captured value, so references
732- // must be taken outside the closure.
733- let rlibs = & mut rlibs;
734- let rmetas = & mut rmetas;
735- let dylibs = & mut dylibs;
736- let type_via_filename = ( || {
737- if file. starts_with ( "lib" ) {
738- if file. ends_with ( ".rlib" ) {
739- return Some ( rlibs) ;
740- }
741- if file. ends_with ( ".rmeta" ) {
742- return Some ( rmetas) ;
743- }
744- }
745- let dll_prefix = self . target . dll_prefix . as_ref ( ) ;
746- let dll_suffix = self . target . dll_suffix . as_ref ( ) ;
747- if file. starts_with ( dll_prefix) && file. ends_with ( dll_suffix) {
748- return Some ( dylibs) ;
749- }
750- None
751- } ) ( ) ;
752- match type_via_filename {
753- Some ( type_via_filename) => {
754- type_via_filename. insert ( loc_canon. clone ( ) , PathKind :: ExternFlag ) ;
731+ if file. starts_with ( "lib" ) {
732+ if file. ends_with ( ".rlib" ) {
733+ rlibs. insert ( loc_canon. clone ( ) , PathKind :: ExternFlag ) ;
734+ continue ;
755735 }
756- None => {
757- self . crate_rejections
758- . via_filename
759- . push ( CrateMismatch { path : loc_orig. clone ( ) , got : String :: new ( ) } ) ;
736+ if file. ends_with ( ".rmeta" ) {
737+ rmetas. insert ( loc_canon. clone ( ) , PathKind :: ExternFlag ) ;
738+ continue ;
760739 }
761740 }
741+ let dll_prefix = self . target . dll_prefix . as_ref ( ) ;
742+ let dll_suffix = self . target . dll_suffix . as_ref ( ) ;
743+ if file. starts_with ( dll_prefix) && file. ends_with ( dll_suffix) {
744+ dylibs. insert ( loc_canon. clone ( ) , PathKind :: ExternFlag ) ;
745+ continue ;
746+ }
747+ self . crate_rejections
748+ . via_filename
749+ . push ( CrateMismatch { path : loc_orig. clone ( ) , got : String :: new ( ) } ) ;
762750 }
763751
764752 // Extract the dylib/rlib/rmeta triple.
0 commit comments