@@ -596,37 +596,38 @@ pub fn host_triple() -> &'static str {
596596 ( option_env ! ( "CFG_COMPILER_HOST_TRIPLE" ) ) . expect ( "CFG_COMPILER_HOST_TRIPLE" )
597597}
598598
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+ }
630631 }
631632}
632633
@@ -2529,6 +2530,7 @@ mod tests {
25292530 use syntax:: symbol:: Symbol ;
25302531 use syntax:: edition:: { Edition , DEFAULT_EDITION } ;
25312532 use syntax;
2533+ use super :: Options ;
25322534
25332535 fn optgroups ( ) -> getopts:: Options {
25342536 let mut opts = getopts:: Options :: new ( ) ;
@@ -2613,9 +2615,9 @@ mod tests {
26132615
26142616 #[ test]
26152617 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 ( ) ;
26192621
26202622 v1. output_types =
26212623 OutputTypes :: new ( & [ ( OutputType :: Exe , Some ( PathBuf :: from ( "./some/thing" ) ) ) ] ) ;
@@ -2635,8 +2637,8 @@ mod tests {
26352637
26362638 #[ test]
26372639 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 ( ) ;
26402642
26412643 v1. output_types = OutputTypes :: new ( & [
26422644 ( OutputType :: Exe , Some ( PathBuf :: from ( "./some/thing" ) ) ) ,
@@ -2656,9 +2658,9 @@ mod tests {
26562658
26572659 #[ test]
26582660 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 ( ) ;
26622664
26632665 v1. externs = Externs :: new ( mk_map ( vec ! [
26642666 (
@@ -2705,9 +2707,9 @@ mod tests {
27052707
27062708 #[ test]
27072709 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 ( ) ;
27112713
27122714 v1. lint_opts = vec ! [
27132715 ( String :: from( "a" ) , lint:: Allow ) ,
@@ -2742,8 +2744,8 @@ mod tests {
27422744
27432745 #[ test]
27442746 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 ( ) ;
27472749
27482750 v1. lint_opts = vec ! [
27492751 ( String :: from( "a" ) , lint:: Allow ) ,
@@ -2768,10 +2770,10 @@ mod tests {
27682770
27692771 #[ test]
27702772 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 ( ) ;
27752777
27762778 // Reference
27772779 v1. search_paths
@@ -2831,10 +2833,10 @@ mod tests {
28312833
28322834 #[ test]
28332835 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 ( ) ;
28382840
28392841 // Reference
28402842 v1. libs = vec ! [
@@ -2881,9 +2883,9 @@ mod tests {
28812883
28822884 #[ test]
28832885 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 ( ) ;
28872889
28882890 // Reference
28892891 v1. libs = vec ! [
@@ -2916,8 +2918,8 @@ mod tests {
29162918
29172919 #[ test]
29182920 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 ( ) ;
29212923
29222924 // Make sure the changing an [UNTRACKED] option leaves the hash unchanged
29232925 opts. cg . ar = Some ( String :: from ( "abc" ) ) ;
@@ -3054,8 +3056,8 @@ mod tests {
30543056
30553057 #[ test]
30563058 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 ( ) ;
30593061
30603062 // Make sure the changing an [UNTRACKED] option leaves the hash unchanged
30613063 opts. debugging_opts . verbose = true ;
@@ -3184,7 +3186,7 @@ mod tests {
31843186 #[ test]
31853187 fn test_edition_parsing ( ) {
31863188 // test default edition
3187- let options = super :: basic_options ( ) ;
3189+ let options = Options :: default ( ) ;
31883190 assert ! ( options. edition == DEFAULT_EDITION ) ;
31893191
31903192 let matches = optgroups ( )
0 commit comments