@@ -157,7 +157,7 @@ pub fn run_compiler<'a>(args: &[String],
157157 }
158158 } }
159159
160- let matches = match handle_options ( args. to_vec ( ) ) {
160+ let matches = match handle_options ( args) {
161161 Some ( matches) => matches,
162162 None => return ( Ok ( ( ) ) , None ) ,
163163 } ;
@@ -335,10 +335,10 @@ pub struct RustcDefaultCalls;
335335fn handle_explain ( code : & str ,
336336 descriptions : & diagnostics:: registry:: Registry ,
337337 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" ) {
341339 code. to_string ( )
340+ } else {
341+ format ! ( "E{0:0>4}" , code)
342342 } ;
343343 match descriptions. find_description ( & normalised) {
344344 Some ( ref description) => {
@@ -870,9 +870,9 @@ fn print_flag_list<T>(cmdline_opt: &str,
870870///
871871/// So with all that in mind, the comments below have some more detail about the
872872/// 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 > {
874874 // Throw away the first argument, the name of the binary
875- let _binary = args. remove ( 0 ) ;
875+ let args = & args[ 1 .. ] ;
876876
877877 if args. is_empty ( ) {
878878 // 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> {
916916 if opt. stability == OptionStability :: Stable {
917917 continue
918918 }
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 ( ) {
922920 & opt. opt_group . short_name
921+ } else {
922+ & opt. opt_group . long_name
923923 } ;
924924 if !matches. opt_present ( opt_name) {
925925 continue
@@ -1033,43 +1033,38 @@ pub fn monitor<F: FnOnce() + Send + 'static>(f: F) {
10331033 cfg = cfg. stack_size ( STACK_SIZE ) ;
10341034 }
10351035
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+ } ) ;
10551040
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 ) ;
10671045
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 ) ;
10691050 }
10701051
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( ) ) ;
10721065 }
1066+
1067+ exit_on_err ( ) ;
10731068 }
10741069}
10751070
0 commit comments