@@ -44,7 +44,7 @@ use serialize::json;
4444
4545use  std:: any:: Any ; 
4646use  std:: env; 
47- use  std:: ffi:: { OsStr ,   OsString } ; 
47+ use  std:: ffi:: OsString ; 
4848use  std:: fs; 
4949use  std:: io:: { self ,  Write } ; 
5050use  std:: iter; 
@@ -1021,6 +1021,7 @@ where
10211021            . cloned ( ) 
10221022            . collect ( ) ; 
10231023        missing_fragment_specifiers. sort ( ) ; 
1024+ 
10241025        for  span in  missing_fragment_specifiers { 
10251026            let  lint = lint:: builtin:: MISSING_FRAGMENT_SPECIFIER ; 
10261027            let  msg = "missing fragment specifier" ; 
@@ -1472,7 +1473,7 @@ fn write_out_deps(sess: &Session, outputs: &OutputFilenames, out_filenames: &[Pa
14721473            . collect ( ) ; 
14731474        let  mut  file = fs:: File :: create ( & deps_filename) ?; 
14741475        for  path in  out_filenames { 
1475-             write ! ( file,  "{}: {}\n \n " ,  path. display( ) ,  files. join( " " ) ) ?; 
1476+             writeln ! ( file,  "{}: {}\n " ,  path. display( ) ,  files. join( " " ) ) ?; 
14761477        } 
14771478
14781479        // Emit a fake target for each input file to the compilation. This 
@@ -1484,15 +1485,12 @@ fn write_out_deps(sess: &Session, outputs: &OutputFilenames, out_filenames: &[Pa
14841485        Ok ( ( ) ) 
14851486    } ) ( ) ; 
14861487
1487-     match  result { 
1488-         Ok ( ( ) )  => { } 
1489-         Err ( e)  => { 
1490-             sess. fatal ( & format ! ( 
1491-                 "error writing dependencies to `{}`: {}" , 
1492-                 deps_filename. display( ) , 
1493-                 e
1494-             ) ) ; 
1495-         } 
1488+     if  let  Err ( e)  = result { 
1489+         sess. fatal ( & format ! ( 
1490+             "error writing dependencies to `{}`: {}" , 
1491+             deps_filename. display( ) , 
1492+             e
1493+         ) ) ; 
14961494    } 
14971495} 
14981496
@@ -1520,6 +1518,7 @@ pub fn collect_crate_types(session: &Session, attrs: &[ast::Attribute]) -> Vec<c
15201518                            Symbol :: intern( "proc-macro" ) , 
15211519                            Symbol :: intern( "bin" ) 
15221520                        ] ; 
1521+ 
15231522                        if  let  ast:: MetaItemKind :: NameValue ( spanned)  = a. meta ( ) . unwrap ( ) . node  { 
15241523                            let  span = spanned. span ; 
15251524                            let  lev_candidate = find_best_match_for_name ( 
@@ -1551,7 +1550,7 @@ pub fn collect_crate_types(session: &Session, attrs: &[ast::Attribute]) -> Vec<c
15511550                        } 
15521551                        None 
15531552                    } 
1554-                     _  => { 
1553+                     None  => { 
15551554                        session
15561555                            . struct_span_err ( a. span ,  "`crate_type` requires a value" ) 
15571556                            . note ( "for example: `#![crate_type=\" lib\" ]`" ) 
@@ -1581,25 +1580,26 @@ pub fn collect_crate_types(session: &Session, attrs: &[ast::Attribute]) -> Vec<c
15811580            base. push ( :: rustc_codegen_utils:: link:: default_output_for_target ( 
15821581                session, 
15831582            ) ) ; 
1583+         }  else  { 
1584+             base. sort ( ) ; 
1585+             base. dedup ( ) ; 
15841586        } 
1585-         base. sort ( ) ; 
1586-         base. dedup ( ) ; 
15871587    } 
15881588
1589-     base. into_iter ( ) 
1590-         . filter ( |crate_type| { 
1591-             let  res = !:: rustc_codegen_utils:: link:: invalid_output_for_target ( session,  * crate_type) ; 
1589+     base. retain ( |crate_type| { 
1590+         let  res = !:: rustc_codegen_utils:: link:: invalid_output_for_target ( session,  * crate_type) ; 
15921591
1593-              if  !res { 
1594-                  session. warn ( & format ! ( 
1595-                      "dropping unsupported crate type `{}` for target `{}`" , 
1596-                      * crate_type,  session. opts. target_triple
1597-                  ) ) ; 
1598-              } 
1592+         if  !res { 
1593+             session. warn ( & format ! ( 
1594+                 "dropping unsupported crate type `{}` for target `{}`" , 
1595+                 * crate_type,  session. opts. target_triple
1596+             ) ) ; 
1597+         } 
15991598
1600-             res
1601-         } ) 
1602-         . collect ( ) 
1599+         res
1600+     } ) ; 
1601+ 
1602+     base
16031603} 
16041604
16051605pub  fn  compute_crate_disambiguator ( session :  & Session )  -> CrateDisambiguator  { 
@@ -1650,17 +1650,14 @@ pub fn build_output_filenames(
16501650            // "-" as input file will cause the parser to read from stdin so we 
16511651            // have to make up a name 
16521652            // We want to toss everything after the final '.' 
1653-             let  dirpath = match  * odir { 
1654-                 Some ( ref  d)  => d. clone ( ) , 
1655-                 None  => PathBuf :: new ( ) , 
1656-             } ; 
1653+             let  dirpath = ( * odir) . as_ref ( ) . cloned ( ) . unwrap_or_default ( ) ; 
16571654
16581655            // If a crate name is present, we use it as the link name 
16591656            let  stem = sess. opts 
16601657                . crate_name 
16611658                . clone ( ) 
16621659                . or_else ( || attr:: find_crate_name ( attrs) . map ( |n| n. to_string ( ) ) ) 
1663-                 . unwrap_or ( input. filestem ( ) ) ; 
1660+                 . unwrap_or_else ( ||  input. filestem ( ) ) ; 
16641661
16651662            OutputFilenames  { 
16661663                out_directory :  dirpath, 
@@ -1693,13 +1690,11 @@ pub fn build_output_filenames(
16931690                sess. warn ( "ignoring -C extra-filename flag due to -o flag" ) ; 
16941691            } 
16951692
1696-             let  cur_dir = Path :: new ( "" ) ; 
1697- 
16981693            OutputFilenames  { 
1699-                 out_directory :  out_file. parent ( ) . unwrap_or ( cur_dir ) . to_path_buf ( ) , 
1694+                 out_directory :  out_file. parent ( ) . unwrap_or_else ( ||  Path :: new ( "" ) ) . to_path_buf ( ) , 
17001695                out_filestem :  out_file
17011696                    . file_stem ( ) 
1702-                     . unwrap_or ( OsStr :: new ( "" ) ) 
1697+                     . unwrap_or_default ( ) 
17031698                    . to_str ( ) 
17041699                    . unwrap ( ) 
17051700                    . to_string ( ) , 
0 commit comments