@@ -596,37 +596,38 @@ pub fn host_triple() -> &'static str {
596
596
( option_env ! ( "CFG_COMPILER_HOST_TRIPLE" ) ) . expect ( "CFG_COMPILER_HOST_TRIPLE" )
597
597
}
598
598
599
- /// Some reasonable defaults
600
- pub fn basic_options ( ) -> Options {
601
- Options {
602
- crate_types : Vec :: new ( ) ,
603
- optimize : OptLevel :: No ,
604
- debuginfo : DebugInfo :: None ,
605
- lint_opts : Vec :: new ( ) ,
606
- lint_cap : None ,
607
- describe_lints : false ,
608
- output_types : OutputTypes ( BTreeMap :: new ( ) ) ,
609
- search_paths : SearchPaths :: new ( ) ,
610
- maybe_sysroot : None ,
611
- target_triple : TargetTriple :: from_triple ( host_triple ( ) ) ,
612
- test : false ,
613
- incremental : None ,
614
- debugging_opts : basic_debugging_options ( ) ,
615
- prints : Vec :: new ( ) ,
616
- borrowck_mode : BorrowckMode :: Ast ,
617
- cg : basic_codegen_options ( ) ,
618
- error_format : ErrorOutputType :: default ( ) ,
619
- externs : Externs ( BTreeMap :: new ( ) ) ,
620
- crate_name : None ,
621
- alt_std_name : None ,
622
- libs : Vec :: new ( ) ,
623
- unstable_features : UnstableFeatures :: Disallow ,
624
- debug_assertions : true ,
625
- actually_rustdoc : false ,
626
- cli_forced_codegen_units : None ,
627
- cli_forced_thinlto_off : false ,
628
- remap_path_prefix : Vec :: new ( ) ,
629
- edition : DEFAULT_EDITION ,
599
+ impl Default for Options {
600
+ fn default ( ) -> Options {
601
+ Options {
602
+ crate_types : Vec :: new ( ) ,
603
+ optimize : OptLevel :: No ,
604
+ debuginfo : DebugInfo :: None ,
605
+ lint_opts : Vec :: new ( ) ,
606
+ lint_cap : None ,
607
+ describe_lints : false ,
608
+ output_types : OutputTypes ( BTreeMap :: new ( ) ) ,
609
+ search_paths : SearchPaths :: new ( ) ,
610
+ maybe_sysroot : None ,
611
+ target_triple : TargetTriple :: from_triple ( host_triple ( ) ) ,
612
+ test : false ,
613
+ incremental : None ,
614
+ debugging_opts : basic_debugging_options ( ) ,
615
+ prints : Vec :: new ( ) ,
616
+ borrowck_mode : BorrowckMode :: Ast ,
617
+ cg : basic_codegen_options ( ) ,
618
+ error_format : ErrorOutputType :: default ( ) ,
619
+ externs : Externs ( BTreeMap :: new ( ) ) ,
620
+ crate_name : None ,
621
+ alt_std_name : None ,
622
+ libs : Vec :: new ( ) ,
623
+ unstable_features : UnstableFeatures :: Disallow ,
624
+ debug_assertions : true ,
625
+ actually_rustdoc : false ,
626
+ cli_forced_codegen_units : None ,
627
+ cli_forced_thinlto_off : false ,
628
+ remap_path_prefix : Vec :: new ( ) ,
629
+ edition : DEFAULT_EDITION ,
630
+ }
630
631
}
631
632
}
632
633
@@ -2529,6 +2530,7 @@ mod tests {
2529
2530
use syntax:: symbol:: Symbol ;
2530
2531
use syntax:: edition:: { Edition , DEFAULT_EDITION } ;
2531
2532
use syntax;
2533
+ use super :: Options ;
2532
2534
2533
2535
fn optgroups ( ) -> getopts:: Options {
2534
2536
let mut opts = getopts:: Options :: new ( ) ;
@@ -2613,9 +2615,9 @@ mod tests {
2613
2615
2614
2616
#[ test]
2615
2617
fn test_output_types_tracking_hash_different_paths ( ) {
2616
- let mut v1 = super :: basic_options ( ) ;
2617
- let mut v2 = super :: basic_options ( ) ;
2618
- let mut v3 = super :: basic_options ( ) ;
2618
+ let mut v1 = Options :: default ( ) ;
2619
+ let mut v2 = Options :: default ( ) ;
2620
+ let mut v3 = Options :: default ( ) ;
2619
2621
2620
2622
v1. output_types =
2621
2623
OutputTypes :: new ( & [ ( OutputType :: Exe , Some ( PathBuf :: from ( "./some/thing" ) ) ) ] ) ;
@@ -2635,8 +2637,8 @@ mod tests {
2635
2637
2636
2638
#[ test]
2637
2639
fn test_output_types_tracking_hash_different_construction_order ( ) {
2638
- let mut v1 = super :: basic_options ( ) ;
2639
- let mut v2 = super :: basic_options ( ) ;
2640
+ let mut v1 = Options :: default ( ) ;
2641
+ let mut v2 = Options :: default ( ) ;
2640
2642
2641
2643
v1. output_types = OutputTypes :: new ( & [
2642
2644
( OutputType :: Exe , Some ( PathBuf :: from ( "./some/thing" ) ) ) ,
@@ -2656,9 +2658,9 @@ mod tests {
2656
2658
2657
2659
#[ test]
2658
2660
fn test_externs_tracking_hash_different_construction_order ( ) {
2659
- let mut v1 = super :: basic_options ( ) ;
2660
- let mut v2 = super :: basic_options ( ) ;
2661
- let mut v3 = super :: basic_options ( ) ;
2661
+ let mut v1 = Options :: default ( ) ;
2662
+ let mut v2 = Options :: default ( ) ;
2663
+ let mut v3 = Options :: default ( ) ;
2662
2664
2663
2665
v1. externs = Externs :: new ( mk_map ( vec ! [
2664
2666
(
@@ -2705,9 +2707,9 @@ mod tests {
2705
2707
2706
2708
#[ test]
2707
2709
fn test_lints_tracking_hash_different_values ( ) {
2708
- let mut v1 = super :: basic_options ( ) ;
2709
- let mut v2 = super :: basic_options ( ) ;
2710
- let mut v3 = super :: basic_options ( ) ;
2710
+ let mut v1 = Options :: default ( ) ;
2711
+ let mut v2 = Options :: default ( ) ;
2712
+ let mut v3 = Options :: default ( ) ;
2711
2713
2712
2714
v1. lint_opts = vec ! [
2713
2715
( String :: from( "a" ) , lint:: Allow ) ,
@@ -2742,8 +2744,8 @@ mod tests {
2742
2744
2743
2745
#[ test]
2744
2746
fn test_lints_tracking_hash_different_construction_order ( ) {
2745
- let mut v1 = super :: basic_options ( ) ;
2746
- let mut v2 = super :: basic_options ( ) ;
2747
+ let mut v1 = Options :: default ( ) ;
2748
+ let mut v2 = Options :: default ( ) ;
2747
2749
2748
2750
v1. lint_opts = vec ! [
2749
2751
( String :: from( "a" ) , lint:: Allow ) ,
@@ -2768,10 +2770,10 @@ mod tests {
2768
2770
2769
2771
#[ test]
2770
2772
fn test_search_paths_tracking_hash_different_order ( ) {
2771
- let mut v1 = super :: basic_options ( ) ;
2772
- let mut v2 = super :: basic_options ( ) ;
2773
- let mut v3 = super :: basic_options ( ) ;
2774
- let mut v4 = super :: basic_options ( ) ;
2773
+ let mut v1 = Options :: default ( ) ;
2774
+ let mut v2 = Options :: default ( ) ;
2775
+ let mut v3 = Options :: default ( ) ;
2776
+ let mut v4 = Options :: default ( ) ;
2775
2777
2776
2778
// Reference
2777
2779
v1. search_paths
@@ -2831,10 +2833,10 @@ mod tests {
2831
2833
2832
2834
#[ test]
2833
2835
fn test_native_libs_tracking_hash_different_values ( ) {
2834
- let mut v1 = super :: basic_options ( ) ;
2835
- let mut v2 = super :: basic_options ( ) ;
2836
- let mut v3 = super :: basic_options ( ) ;
2837
- let mut v4 = super :: basic_options ( ) ;
2836
+ let mut v1 = Options :: default ( ) ;
2837
+ let mut v2 = Options :: default ( ) ;
2838
+ let mut v3 = Options :: default ( ) ;
2839
+ let mut v4 = Options :: default ( ) ;
2838
2840
2839
2841
// Reference
2840
2842
v1. libs = vec ! [
@@ -2881,9 +2883,9 @@ mod tests {
2881
2883
2882
2884
#[ test]
2883
2885
fn test_native_libs_tracking_hash_different_order ( ) {
2884
- let mut v1 = super :: basic_options ( ) ;
2885
- let mut v2 = super :: basic_options ( ) ;
2886
- let mut v3 = super :: basic_options ( ) ;
2886
+ let mut v1 = Options :: default ( ) ;
2887
+ let mut v2 = Options :: default ( ) ;
2888
+ let mut v3 = Options :: default ( ) ;
2887
2889
2888
2890
// Reference
2889
2891
v1. libs = vec ! [
@@ -2916,8 +2918,8 @@ mod tests {
2916
2918
2917
2919
#[ test]
2918
2920
fn test_codegen_options_tracking_hash ( ) {
2919
- let reference = super :: basic_options ( ) ;
2920
- let mut opts = super :: basic_options ( ) ;
2921
+ let reference = Options :: default ( ) ;
2922
+ let mut opts = Options :: default ( ) ;
2921
2923
2922
2924
// Make sure the changing an [UNTRACKED] option leaves the hash unchanged
2923
2925
opts. cg . ar = Some ( String :: from ( "abc" ) ) ;
@@ -3054,8 +3056,8 @@ mod tests {
3054
3056
3055
3057
#[ test]
3056
3058
fn test_debugging_options_tracking_hash ( ) {
3057
- let reference = super :: basic_options ( ) ;
3058
- let mut opts = super :: basic_options ( ) ;
3059
+ let reference = Options :: default ( ) ;
3060
+ let mut opts = Options :: default ( ) ;
3059
3061
3060
3062
// Make sure the changing an [UNTRACKED] option leaves the hash unchanged
3061
3063
opts. debugging_opts . verbose = true ;
@@ -3184,7 +3186,7 @@ mod tests {
3184
3186
#[ test]
3185
3187
fn test_edition_parsing ( ) {
3186
3188
// test default edition
3187
- let options = super :: basic_options ( ) ;
3189
+ let options = Options :: default ( ) ;
3188
3190
assert ! ( options. edition == DEFAULT_EDITION ) ;
3189
3191
3190
3192
let matches = optgroups ( )
0 commit comments