@@ -44,7 +44,7 @@ use serialize::json;
44
44
45
45
use std:: any:: Any ;
46
46
use std:: env;
47
- use std:: ffi:: { OsStr , OsString } ;
47
+ use std:: ffi:: OsString ;
48
48
use std:: fs;
49
49
use std:: io:: { self , Write } ;
50
50
use std:: iter;
@@ -1021,6 +1021,7 @@ where
1021
1021
. cloned ( )
1022
1022
. collect ( ) ;
1023
1023
missing_fragment_specifiers. sort ( ) ;
1024
+
1024
1025
for span in missing_fragment_specifiers {
1025
1026
let lint = lint:: builtin:: MISSING_FRAGMENT_SPECIFIER ;
1026
1027
let msg = "missing fragment specifier" ;
@@ -1472,7 +1473,7 @@ fn write_out_deps(sess: &Session, outputs: &OutputFilenames, out_filenames: &[Pa
1472
1473
. collect ( ) ;
1473
1474
let mut file = fs:: File :: create ( & deps_filename) ?;
1474
1475
for path in out_filenames {
1475
- write ! ( file, "{}: {}\n \n " , path. display( ) , files. join( " " ) ) ?;
1476
+ writeln ! ( file, "{}: {}\n " , path. display( ) , files. join( " " ) ) ?;
1476
1477
}
1477
1478
1478
1479
// 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
1484
1485
Ok ( ( ) )
1485
1486
} ) ( ) ;
1486
1487
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
+ ) ) ;
1496
1494
}
1497
1495
}
1498
1496
@@ -1520,6 +1518,7 @@ pub fn collect_crate_types(session: &Session, attrs: &[ast::Attribute]) -> Vec<c
1520
1518
Symbol :: intern( "proc-macro" ) ,
1521
1519
Symbol :: intern( "bin" )
1522
1520
] ;
1521
+
1523
1522
if let ast:: MetaItemKind :: NameValue ( spanned) = a. meta ( ) . unwrap ( ) . node {
1524
1523
let span = spanned. span ;
1525
1524
let lev_candidate = find_best_match_for_name (
@@ -1551,7 +1550,7 @@ pub fn collect_crate_types(session: &Session, attrs: &[ast::Attribute]) -> Vec<c
1551
1550
}
1552
1551
None
1553
1552
}
1554
- _ => {
1553
+ None => {
1555
1554
session
1556
1555
. struct_span_err ( a. span , "`crate_type` requires a value" )
1557
1556
. note ( "for example: `#![crate_type=\" lib\" ]`" )
@@ -1581,25 +1580,26 @@ pub fn collect_crate_types(session: &Session, attrs: &[ast::Attribute]) -> Vec<c
1581
1580
base. push ( :: rustc_codegen_utils:: link:: default_output_for_target (
1582
1581
session,
1583
1582
) ) ;
1583
+ } else {
1584
+ base. sort ( ) ;
1585
+ base. dedup ( ) ;
1584
1586
}
1585
- base. sort ( ) ;
1586
- base. dedup ( ) ;
1587
1587
}
1588
1588
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) ;
1592
1591
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
+ }
1599
1598
1600
- res
1601
- } )
1602
- . collect ( )
1599
+ res
1600
+ } ) ;
1601
+
1602
+ base
1603
1603
}
1604
1604
1605
1605
pub fn compute_crate_disambiguator ( session : & Session ) -> CrateDisambiguator {
@@ -1650,17 +1650,14 @@ pub fn build_output_filenames(
1650
1650
// "-" as input file will cause the parser to read from stdin so we
1651
1651
// have to make up a name
1652
1652
// 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 ( ) ;
1657
1654
1658
1655
// If a crate name is present, we use it as the link name
1659
1656
let stem = sess. opts
1660
1657
. crate_name
1661
1658
. clone ( )
1662
1659
. or_else ( || attr:: find_crate_name ( attrs) . map ( |n| n. to_string ( ) ) )
1663
- . unwrap_or ( input. filestem ( ) ) ;
1660
+ . unwrap_or_else ( || input. filestem ( ) ) ;
1664
1661
1665
1662
OutputFilenames {
1666
1663
out_directory : dirpath,
@@ -1693,13 +1690,11 @@ pub fn build_output_filenames(
1693
1690
sess. warn ( "ignoring -C extra-filename flag due to -o flag" ) ;
1694
1691
}
1695
1692
1696
- let cur_dir = Path :: new ( "" ) ;
1697
-
1698
1693
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 ( ) ,
1700
1695
out_filestem : out_file
1701
1696
. file_stem ( )
1702
- . unwrap_or ( OsStr :: new ( "" ) )
1697
+ . unwrap_or_default ( )
1703
1698
. to_str ( )
1704
1699
. unwrap ( )
1705
1700
. to_string ( ) ,
0 commit comments