@@ -157,7 +157,7 @@ pub fn run_compiler<'a>(args: &[String],
157
157
}
158
158
} }
159
159
160
- let matches = match handle_options ( args. to_vec ( ) ) {
160
+ let matches = match handle_options ( args) {
161
161
Some ( matches) => matches,
162
162
None => return ( Ok ( ( ) ) , None ) ,
163
163
} ;
@@ -335,10 +335,10 @@ pub struct RustcDefaultCalls;
335
335
fn handle_explain ( code : & str ,
336
336
descriptions : & diagnostics:: registry:: Registry ,
337
337
output : ErrorOutputType ) {
338
- let normalised = if !code. starts_with ( "E" ) {
339
- format ! ( "E{0:0>4}" , code)
340
- } else {
338
+ let normalised = if code. starts_with ( "E" ) {
341
339
code. to_string ( )
340
+ } else {
341
+ format ! ( "E{0:0>4}" , code)
342
342
} ;
343
343
match descriptions. find_description ( & normalised) {
344
344
Some ( ref description) => {
@@ -870,9 +870,9 @@ fn print_flag_list<T>(cmdline_opt: &str,
870
870
///
871
871
/// So with all that in mind, the comments below have some more detail about the
872
872
/// contortions done here to get things to work out correctly.
873
- pub fn handle_options ( mut args : Vec < String > ) -> Option < getopts:: Matches > {
873
+ pub fn handle_options ( args : & [ String ] ) -> Option < getopts:: Matches > {
874
874
// Throw away the first argument, the name of the binary
875
- let _binary = args. remove ( 0 ) ;
875
+ let args = & args[ 1 .. ] ;
876
876
877
877
if args. is_empty ( ) {
878
878
// user did not write `-v` nor `-Z unstable-options`, so do not
@@ -916,10 +916,10 @@ pub fn handle_options(mut args: Vec<String>) -> Option<getopts::Matches> {
916
916
if opt. stability == OptionStability :: Stable {
917
917
continue
918
918
}
919
- let opt_name = if !opt. opt_group . long_name . is_empty ( ) {
920
- & opt. opt_group . long_name
921
- } else {
919
+ let opt_name = if opt. opt_group . long_name . is_empty ( ) {
922
920
& opt. opt_group . short_name
921
+ } else {
922
+ & opt. opt_group . long_name
923
923
} ;
924
924
if !matches. opt_present ( opt_name) {
925
925
continue
@@ -1033,43 +1033,38 @@ pub fn monitor<F: FnOnce() + Send + 'static>(f: F) {
1033
1033
cfg = cfg. stack_size ( STACK_SIZE ) ;
1034
1034
}
1035
1035
1036
- match cfg. spawn ( move || {
1037
- io:: set_panic ( box err) ;
1038
- f ( )
1039
- } )
1040
- . unwrap ( )
1041
- . join ( ) {
1042
- Ok ( ( ) ) => {
1043
- // fallthrough
1044
- }
1045
- Err ( value) => {
1046
- // Thread panicked without emitting a fatal diagnostic
1047
- if !value. is :: < errors:: FatalError > ( ) {
1048
- let mut emitter = errors:: emitter:: BasicEmitter :: stderr ( errors:: ColorConfig :: Auto ) ;
1049
-
1050
- // a .span_bug or .bug call has already printed what
1051
- // it wants to print.
1052
- if !value. is :: < errors:: ExplicitBug > ( ) {
1053
- emitter. emit ( None , "unexpected panic" , None , errors:: Level :: Bug ) ;
1054
- }
1036
+ let thread = cfg. spawn ( move || {
1037
+ io:: set_panic ( box err) ;
1038
+ f ( )
1039
+ } ) ;
1055
1040
1056
- let xs = [ "the compiler unexpectedly panicked. this is a bug." . to_string ( ) ,
1057
- format ! ( "we would appreciate a bug report: {}" , BUG_REPORT_URL ) ] ;
1058
- for note in & xs {
1059
- emitter. emit ( None , & note[ ..] , None , errors:: Level :: Note )
1060
- }
1061
- if let None = env:: var_os ( "RUST_BACKTRACE" ) {
1062
- emitter. emit ( None ,
1063
- "run with `RUST_BACKTRACE=1` for a backtrace" ,
1064
- None ,
1065
- errors:: Level :: Note ) ;
1066
- }
1041
+ if let Err ( value) = thread. unwrap ( ) . join ( ) {
1042
+ // Thread panicked without emitting a fatal diagnostic
1043
+ if !value. is :: < errors:: FatalError > ( ) {
1044
+ let mut emitter = errors:: emitter:: BasicEmitter :: stderr ( errors:: ColorConfig :: Auto ) ;
1067
1045
1068
- println ! ( "{}" , str :: from_utf8( & data. lock( ) . unwrap( ) ) . unwrap( ) ) ;
1046
+ // a .span_bug or .bug call has already printed what
1047
+ // it wants to print.
1048
+ if !value. is :: < errors:: ExplicitBug > ( ) {
1049
+ emitter. emit ( None , "unexpected panic" , None , errors:: Level :: Bug ) ;
1069
1050
}
1070
1051
1071
- exit_on_err ( ) ;
1052
+ let xs = [ "the compiler unexpectedly panicked. this is a bug." . to_string ( ) ,
1053
+ format ! ( "we would appreciate a bug report: {}" , BUG_REPORT_URL ) ] ;
1054
+ for note in & xs {
1055
+ emitter. emit ( None , & note[ ..] , None , errors:: Level :: Note )
1056
+ }
1057
+ if let None = env:: var_os ( "RUST_BACKTRACE" ) {
1058
+ emitter. emit ( None ,
1059
+ "run with `RUST_BACKTRACE=1` for a backtrace" ,
1060
+ None ,
1061
+ errors:: Level :: Note ) ;
1062
+ }
1063
+
1064
+ println ! ( "{}" , str :: from_utf8( & data. lock( ) . unwrap( ) ) . unwrap( ) ) ;
1072
1065
}
1066
+
1067
+ exit_on_err ( ) ;
1073
1068
}
1074
1069
}
1075
1070
0 commit comments