@@ -87,11 +87,11 @@ use std::env;
8787use std:: ffi:: OsString ;
8888use std:: io:: { self , Read , Write } ;
8989use std:: iter:: repeat;
90+ use std:: panic;
9091use std:: path:: PathBuf ;
9192use std:: process:: { self , Command , Stdio } ;
9293use std:: rc:: Rc ;
9394use std:: str;
94- use std:: sync:: { Arc , Mutex } ;
9595use std:: thread;
9696
9797use syntax:: ast;
@@ -168,7 +168,7 @@ pub fn run<F>(run_compiler: F) -> isize
168168 handler. emit ( & MultiSpan :: new ( ) ,
169169 "aborting due to previous error(s)" ,
170170 errors:: Level :: Fatal ) ;
171- exit_on_err ( ) ;
171+ panic :: resume_unwind ( Box :: new ( errors :: FatalErrorMarker ) ) ;
172172 }
173173 }
174174 }
@@ -1228,27 +1228,16 @@ pub fn in_rustc_thread<F, R>(f: F) -> Result<R, Box<Any + Send>>
12281228/// The diagnostic emitter yielded to the procedure should be used for reporting
12291229/// errors of the compiler.
12301230pub fn monitor < F : FnOnce ( ) + Send + ' static > ( f : F ) {
1231- struct Sink ( Arc < Mutex < Vec < u8 > > > ) ;
1232- impl Write for Sink {
1233- fn write ( & mut self , data : & [ u8 ] ) -> io:: Result < usize > {
1234- Write :: write ( & mut * self . 0 . lock ( ) . unwrap ( ) , data)
1235- }
1236- fn flush ( & mut self ) -> io:: Result < ( ) > {
1237- Ok ( ( ) )
1238- }
1239- }
1240-
1241- let data = Arc :: new ( Mutex :: new ( Vec :: new ( ) ) ) ;
1242- let err = Sink ( data. clone ( ) ) ;
1243-
12441231 let result = in_rustc_thread ( move || {
1245- io:: set_panic ( Some ( box err) ) ;
12461232 f ( )
12471233 } ) ;
12481234
12491235 if let Err ( value) = result {
12501236 // Thread panicked without emitting a fatal diagnostic
1251- if !value. is :: < errors:: FatalError > ( ) {
1237+ if !value. is :: < errors:: FatalErrorMarker > ( ) {
1238+ // Emit a newline
1239+ eprintln ! ( "" ) ;
1240+
12521241 let emitter =
12531242 Box :: new ( errors:: emitter:: EmitterWriter :: stderr ( errors:: ColorConfig :: Auto ,
12541243 None ,
@@ -1273,22 +1262,12 @@ pub fn monitor<F: FnOnce() + Send + 'static>(f: F) {
12731262 & note,
12741263 errors:: Level :: Note ) ;
12751264 }
1276-
1277- eprintln ! ( "{}" , str :: from_utf8( & data. lock( ) . unwrap( ) ) . unwrap( ) ) ;
12781265 }
12791266
1280- exit_on_err ( ) ;
1267+ panic :: resume_unwind ( Box :: new ( errors :: FatalErrorMarker ) ) ;
12811268 }
12821269}
12831270
1284- fn exit_on_err ( ) -> ! {
1285- // Panic so the process returns a failure code, but don't pollute the
1286- // output with some unnecessary panic messages, we've already
1287- // printed everything that we needed to.
1288- io:: set_panic ( Some ( box io:: sink ( ) ) ) ;
1289- panic ! ( ) ;
1290- }
1291-
12921271#[ cfg( stage0) ]
12931272pub fn diagnostics_registry ( ) -> errors:: registry:: Registry {
12941273 use errors:: registry:: Registry ;
0 commit comments