@@ -39,9 +39,7 @@ use std::os;
39
39
use std:: vec_ng:: Vec ;
40
40
use std:: vec_ng;
41
41
use collections:: HashMap ;
42
- use getopts:: { optopt, optmulti, optflag, optflagopt, opt} ;
43
- use MaybeHasArg = getopts:: Maybe ;
44
- use OccurOptional = getopts:: Optional ;
42
+ use getopts:: { optopt, optmulti, optflag, optflagopt} ;
45
43
use getopts;
46
44
use syntax:: ast;
47
45
use syntax:: abi;
@@ -866,29 +864,41 @@ pub fn build_session_options(matches: &getopts::Matches)
866
864
}
867
865
Default
868
866
} else if matches. opt_present ( "opt-level" ) {
869
- match matches. opt_str ( "opt-level" ) . unwrap ( ) {
870
- ~"0 " => No ,
871
- ~"1 " => Less ,
872
- ~"2 " => Default ,
873
- ~"3 " => Aggressive ,
874
- _ => {
875
- early_error ( "optimization level needs to be between 0-3" )
876
- }
867
+ match matches. opt_str ( "opt-level" ) . as_ref ( ) . map ( |s| s. as_slice ( ) ) {
868
+ None |
869
+ Some ( "0" ) => No ,
870
+ Some ( "1" ) => Less ,
871
+ Some ( "2" ) => Default ,
872
+ Some ( "3" ) => Aggressive ,
873
+ Some ( arg) => {
874
+ early_error ( format ! ( "optimization level needs to be between 0-3 \
875
+ (instead was `{}`)", arg) ) ;
876
+ }
877
877
}
878
- } else { No }
878
+ } else {
879
+ No
880
+ }
879
881
} ;
880
882
let gc = debugging_opts & session:: GC != 0 ;
881
883
882
- let debuginfo = match matches. opt_default ( "debuginfo" , "2" ) {
883
- Some ( level) => {
884
- match level {
885
- ~"0 " => NoDebugInfo ,
886
- ~"1 " => LimitedDebugInfo ,
887
- ~"2 " => FullDebugInfo ,
888
- _ => early_error ( "debug info level needs to be between 0-2" )
884
+ let debuginfo = if matches. opt_present ( "g" ) {
885
+ if matches. opt_present ( "debuginfo" ) {
886
+ early_error ( "-g and --debuginfo both provided" ) ;
887
+ }
888
+ FullDebugInfo
889
+ } else if matches. opt_present ( "debuginfo" ) {
890
+ match matches. opt_str ( "debuginfo" ) . as_ref ( ) . map ( |s| s. as_slice ( ) ) {
891
+ Some ( "0" ) => NoDebugInfo ,
892
+ Some ( "1" ) => LimitedDebugInfo ,
893
+ None |
894
+ Some ( "2" ) => FullDebugInfo ,
895
+ Some ( arg) => {
896
+ early_error ( format ! ( "optimization level needs to be between 0-3 \
897
+ (instead was `{}`)", arg) ) ;
889
898
}
890
899
}
891
- None => NoDebugInfo
900
+ } else {
901
+ NoDebugInfo
892
902
} ;
893
903
894
904
let addl_lib_search_paths = matches. opt_strs ( "L" ) . map ( |s| {
@@ -1045,11 +1055,11 @@ pub fn optgroups() -> Vec<getopts::OptGroup> {
1045
1055
optflag( "" , "crate-file-name" , "Output the file(s) that would be written if compilation \
1046
1056
continued and exit") ,
1047
1057
optflag( "" , "ls" , "List the symbols defined by a library crate" ) ,
1048
- opt ( "g" , "debuginfo " , "Emit DWARF debug info to the objects created:
1049
- 0 = no debug info,
1050
- 1 = line-tables only (for stacktraces) ,
1051
- 2 = full debug info with variable, argument and type information" ,
1052
- "LEVEL" , MaybeHasArg , OccurOptional ) ,
1058
+ optflag ( "g" , "" , "Equivalent to --debuginfo=2" ) ,
1059
+ optopt ( "" , "debuginfo" , "Emit DWARF debug info to the objects created:
1060
+ 0 = no debug info ,
1061
+ 1 = line-tables only (for stacktraces and breakpoints) ,
1062
+ 2 = full debug info with variable and type information (same as -g)" , "LEVEL" ) ,
1053
1063
optflag( "" , "no-trans" , "Run all passes except translation; no output" ) ,
1054
1064
optflag( "" , "no-analysis" , "Parse and expand the output, but run no analysis or produce output" ) ,
1055
1065
optflag( "O" , "" , "Equivalent to --opt-level=2" ) ,
0 commit comments