@@ -27,7 +27,7 @@ use lint;
27
27
use middle:: cstore;
28
28
29
29
use syntax:: ast:: { self , IntTy , UintTy } ;
30
- use syntax:: codemap:: FilePathMapping ;
30
+ use syntax:: codemap:: { FilePathMapping , FileName } ;
31
31
use syntax:: parse:: token;
32
32
use syntax:: parse;
33
33
use syntax:: symbol:: Symbol ;
@@ -440,7 +440,7 @@ pub enum Input {
440
440
File ( PathBuf ) ,
441
441
Str {
442
442
/// String that is shown in place of a filename
443
- name : String ,
443
+ name : FileName ,
444
444
/// Anonymous source string
445
445
input : String ,
446
446
} ,
@@ -733,7 +733,9 @@ macro_rules! options {
733
733
Some ( "one of: `y`, `yes`, `on`, `n`, `no`, or `off`" ) ;
734
734
pub const parse_string: Option <& ' static str > = Some ( "a string" ) ;
735
735
pub const parse_string_push: Option <& ' static str > = Some ( "a string" ) ;
736
+ pub const parse_pathbuf_push: Option <& ' static str > = Some ( "a path" ) ;
736
737
pub const parse_opt_string: Option <& ' static str > = Some ( "a string" ) ;
738
+ pub const parse_opt_pathbuf: Option <& ' static str > = Some ( "a path" ) ;
737
739
pub const parse_list: Option <& ' static str > = Some ( "a space-separated list of strings" ) ;
738
740
pub const parse_opt_list: Option <& ' static str > = Some ( "a space-separated list of strings" ) ;
739
741
pub const parse_uint: Option <& ' static str > = Some ( "a number" ) ;
@@ -757,6 +759,7 @@ macro_rules! options {
757
759
mod $mod_set {
758
760
use super :: { $struct_name, Passes , SomePasses , AllPasses , Sanitizer } ;
759
761
use rustc_back:: { LinkerFlavor , PanicStrategy , RelroLevel } ;
762
+ use std:: path:: PathBuf ;
760
763
761
764
$(
762
765
pub fn $opt( cg: & mut $struct_name, v: Option <& str >) -> bool {
@@ -797,6 +800,13 @@ macro_rules! options {
797
800
}
798
801
}
799
802
803
+ fn parse_opt_pathbuf( slot: & mut Option <PathBuf >, v: Option <& str >) -> bool {
804
+ match v {
805
+ Some ( s) => { * slot = Some ( PathBuf :: from( s) ) ; true } ,
806
+ None => false ,
807
+ }
808
+ }
809
+
800
810
fn parse_string( slot: & mut String , v: Option <& str >) -> bool {
801
811
match v {
802
812
Some ( s) => { * slot = s. to_string( ) ; true } ,
@@ -811,6 +821,13 @@ macro_rules! options {
811
821
}
812
822
}
813
823
824
+ fn parse_pathbuf_push( slot: & mut Vec <PathBuf >, v: Option <& str >) -> bool {
825
+ match v {
826
+ Some ( s) => { slot. push( PathBuf :: from( s) ) ; true } ,
827
+ None => false ,
828
+ }
829
+ }
830
+
814
831
fn parse_list( slot: & mut Vec <String >, v: Option <& str >)
815
832
-> bool {
816
833
match v {
@@ -931,7 +948,7 @@ options! {CodegenOptions, CodegenSetter, basic_codegen_options,
931
948
CG_OPTIONS , cg_type_desc, cgsetters,
932
949
ar: Option <String > = ( None , parse_opt_string, [ UNTRACKED ] ,
933
950
"this option is deprecated and does nothing" ) ,
934
- linker: Option <String > = ( None , parse_opt_string , [ UNTRACKED ] ,
951
+ linker: Option <PathBuf > = ( None , parse_opt_pathbuf , [ UNTRACKED ] ,
935
952
"system linker to link outputs with" ) ,
936
953
link_arg: Vec <String > = ( vec![ ] , parse_string_push, [ UNTRACKED ] ,
937
954
"a single extra argument to append to the linker invocation (can be used several times)" ) ,
@@ -1151,9 +1168,9 @@ options! {DebuggingOptions, DebuggingSetter, basic_debugging_options,
1151
1168
"set the optimization fuel quota for a crate" ) ,
1152
1169
print_fuel: Option <String > = ( None , parse_opt_string, [ TRACKED ] ,
1153
1170
"make Rustc print the total optimization fuel used by a crate" ) ,
1154
- remap_path_prefix_from: Vec <String > = ( vec![ ] , parse_string_push , [ TRACKED ] ,
1171
+ remap_path_prefix_from: Vec <PathBuf > = ( vec![ ] , parse_pathbuf_push , [ TRACKED ] ,
1155
1172
"add a source pattern to the file path remapping config" ) ,
1156
- remap_path_prefix_to: Vec <String > = ( vec![ ] , parse_string_push , [ TRACKED ] ,
1173
+ remap_path_prefix_to: Vec <PathBuf > = ( vec![ ] , parse_pathbuf_push , [ TRACKED ] ,
1157
1174
"add a mapping target to the file path remapping config" ) ,
1158
1175
force_unstable_if_unmarked: bool = ( false , parse_bool, [ TRACKED ] ,
1159
1176
"force all crates to be `rustc_private` unstable" ) ,
@@ -1472,7 +1489,7 @@ pub fn parse_cfgspecs(cfgspecs: Vec<String> ) -> ast::CrateConfig {
1472
1489
cfgspecs. into_iter ( ) . map ( |s| {
1473
1490
let sess = parse:: ParseSess :: new ( FilePathMapping :: empty ( ) ) ;
1474
1491
let mut parser =
1475
- parse:: new_parser_from_source_str ( & sess, "cfgspec" . to_string ( ) , s. to_string ( ) ) ;
1492
+ parse:: new_parser_from_source_str ( & sess, FileName :: CfgSpec , s. to_string ( ) ) ;
1476
1493
1477
1494
let meta_item = panictry ! ( parser. parse_meta_item( ) ) ;
1478
1495
@@ -1594,13 +1611,13 @@ pub fn build_session_options_and_crate_config(matches: &getopts::Matches)
1594
1611
for source in & debugging_opts. remap_path_prefix_from [ remap_path_prefix_targets..] {
1595
1612
early_error ( error_format,
1596
1613
& format ! ( "option `-Zremap-path-prefix-from='{}'` does not have \
1597
- a corresponding `-Zremap-path-prefix-to`", source) )
1614
+ a corresponding `-Zremap-path-prefix-to`", source. display ( ) ) )
1598
1615
}
1599
1616
} else if remap_path_prefix_targets > remap_path_prefix_sources {
1600
1617
for target in & debugging_opts. remap_path_prefix_to [ remap_path_prefix_sources..] {
1601
1618
early_error ( error_format,
1602
1619
& format ! ( "option `-Zremap-path-prefix-to='{}'` does not have \
1603
- a corresponding `-Zremap-path-prefix-from`", target) )
1620
+ a corresponding `-Zremap-path-prefix-from`", target. display ( ) ) )
1604
1621
}
1605
1622
}
1606
1623
@@ -2001,6 +2018,7 @@ mod dep_tracking {
2001
2018
impl_dep_tracking_hash_via_hash ! ( usize ) ;
2002
2019
impl_dep_tracking_hash_via_hash ! ( u64 ) ;
2003
2020
impl_dep_tracking_hash_via_hash ! ( String ) ;
2021
+ impl_dep_tracking_hash_via_hash ! ( PathBuf ) ;
2004
2022
impl_dep_tracking_hash_via_hash ! ( lint:: Level ) ;
2005
2023
impl_dep_tracking_hash_via_hash ! ( Option <bool >) ;
2006
2024
impl_dep_tracking_hash_via_hash ! ( Option <usize >) ;
@@ -2025,6 +2043,7 @@ mod dep_tracking {
2025
2043
impl_dep_tracking_hash_via_hash ! ( Option <Sanitizer >) ;
2026
2044
2027
2045
impl_dep_tracking_hash_for_sortable_vec_of ! ( String ) ;
2046
+ impl_dep_tracking_hash_for_sortable_vec_of ! ( PathBuf ) ;
2028
2047
impl_dep_tracking_hash_for_sortable_vec_of ! ( CrateType ) ;
2029
2048
impl_dep_tracking_hash_for_sortable_vec_of ! ( ( String , lint:: Level ) ) ;
2030
2049
impl_dep_tracking_hash_for_sortable_vec_of ! ( ( String , Option <String >,
@@ -2533,7 +2552,7 @@ mod tests {
2533
2552
opts. cg . ar = Some ( String :: from ( "abc" ) ) ;
2534
2553
assert_eq ! ( reference. dep_tracking_hash( ) , opts. dep_tracking_hash( ) ) ;
2535
2554
2536
- opts. cg . linker = Some ( String :: from ( "linker" ) ) ;
2555
+ opts. cg . linker = Some ( PathBuf :: from ( "linker" ) ) ;
2537
2556
assert_eq ! ( reference. dep_tracking_hash( ) , opts. dep_tracking_hash( ) ) ;
2538
2557
2539
2558
opts. cg . link_args = Some ( vec ! [ String :: from( "abc" ) , String :: from( "def" ) ] ) ;
0 commit comments