@@ -236,7 +236,13 @@ pub fn each_linked_rlib(
236236)  -> Result < ( ) ,  errors:: LinkRlibError >  { 
237237    let  crates = info. used_crates . iter ( ) ; 
238238
239-     let  fmts = if  crate_type. is_none ( )  { 
239+     let  fmts = if  let  Some ( crate_type)  = crate_type { 
240+         let  Some ( fmts)  = info. dependency_formats . get ( & crate_type)  else  { 
241+             return  Err ( errors:: LinkRlibError :: MissingFormat ) ; 
242+         } ; 
243+ 
244+         fmts
245+     }  else  { 
240246        for  combination in  info. dependency_formats . iter ( ) . combinations ( 2 )  { 
241247            let  ( ty1,  list1)  = & combination[ 0 ] ; 
242248            let  ( ty2,  list2)  = & combination[ 1 ] ; 
@@ -252,18 +258,7 @@ pub fn each_linked_rlib(
252258        if  info. dependency_formats . is_empty ( )  { 
253259            return  Err ( errors:: LinkRlibError :: MissingFormat ) ; 
254260        } 
255-         & info. dependency_formats [ 0 ] . 1 
256-     }  else  { 
257-         let  fmts = info
258-             . dependency_formats 
259-             . iter ( ) 
260-             . find_map ( |& ( ty,  ref  list) | if  Some ( ty)  == crate_type {  Some ( list)  }  else  {  None  } ) ; 
261- 
262-         let  Some ( fmts)  = fmts else  { 
263-             return  Err ( errors:: LinkRlibError :: MissingFormat ) ; 
264-         } ; 
265- 
266-         fmts
261+         info. dependency_formats . first ( ) . unwrap ( ) . 1 
267262    } ; 
268263
269264    for  & cnum in  crates { 
@@ -624,8 +619,7 @@ fn link_staticlib(
624619    let  fmts = codegen_results
625620        . crate_info 
626621        . dependency_formats 
627-         . iter ( ) 
628-         . find_map ( |& ( ty,  ref  list) | if  ty == CrateType :: Staticlib  {  Some ( list)  }  else  {  None  } ) 
622+         . get ( & CrateType :: Staticlib ) 
629623        . expect ( "no dependency formats for staticlib" ) ; 
630624
631625    let  mut  all_rust_dylibs = vec ! [ ] ; 
@@ -2355,11 +2349,10 @@ fn linker_with_args(
23552349    // they are used within inlined functions or instantiated generic functions. We do this *after* 
23562350    // handling the raw-dylib symbols in the current crate to make sure that those are chosen first 
23572351    // by the linker. 
2358-     let  ( _ ,   dependency_linkage)  = codegen_results
2352+     let  dependency_linkage = codegen_results
23592353        . crate_info 
23602354        . dependency_formats 
2361-         . iter ( ) 
2362-         . find ( |( ty,  _) | * ty == crate_type) 
2355+         . get ( & crate_type) 
23632356        . expect ( "failed to find crate type in dependency format list" ) ; 
23642357
23652358    // We sort the libraries below 
@@ -2738,11 +2731,10 @@ fn add_upstream_rust_crates(
27382731    // Linking to a rlib involves just passing it to the linker (the linker 
27392732    // will slurp up the object files inside), and linking to a dynamic library 
27402733    // involves just passing the right -l flag. 
2741-     let  ( _ ,   data)  = codegen_results
2734+     let  data = codegen_results
27422735        . crate_info 
27432736        . dependency_formats 
2744-         . iter ( ) 
2745-         . find ( |( ty,  _) | * ty == crate_type) 
2737+         . get ( & crate_type) 
27462738        . expect ( "failed to find crate type in dependency format list" ) ; 
27472739
27482740    if  sess. target . is_like_aix  { 
0 commit comments