@@ -87,11 +87,11 @@ use std::env;
87
87
use std:: ffi:: OsString ;
88
88
use std:: io:: { self , Read , Write } ;
89
89
use std:: iter:: repeat;
90
+ use std:: panic;
90
91
use std:: path:: PathBuf ;
91
92
use std:: process:: { self , Command , Stdio } ;
92
93
use std:: rc:: Rc ;
93
94
use std:: str;
94
- use std:: sync:: { Arc , Mutex } ;
95
95
use std:: thread;
96
96
97
97
use syntax:: ast;
@@ -168,7 +168,7 @@ pub fn run<F>(run_compiler: F) -> isize
168
168
handler. emit ( & MultiSpan :: new ( ) ,
169
169
"aborting due to previous error(s)" ,
170
170
errors:: Level :: Fatal ) ;
171
- exit_on_err ( ) ;
171
+ panic :: resume_unwind ( Box :: new ( errors :: FatalErrorMarker ) ) ;
172
172
}
173
173
}
174
174
}
@@ -1228,27 +1228,16 @@ pub fn in_rustc_thread<F, R>(f: F) -> Result<R, Box<Any + Send>>
1228
1228
/// The diagnostic emitter yielded to the procedure should be used for reporting
1229
1229
/// errors of the compiler.
1230
1230
pub 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
-
1244
1231
let result = in_rustc_thread ( move || {
1245
- io:: set_panic ( Some ( box err) ) ;
1246
1232
f ( )
1247
1233
} ) ;
1248
1234
1249
1235
if let Err ( value) = result {
1250
1236
// 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
+
1252
1241
let emitter =
1253
1242
Box :: new ( errors:: emitter:: EmitterWriter :: stderr ( errors:: ColorConfig :: Auto ,
1254
1243
None ,
@@ -1273,22 +1262,12 @@ pub fn monitor<F: FnOnce() + Send + 'static>(f: F) {
1273
1262
& note,
1274
1263
errors:: Level :: Note ) ;
1275
1264
}
1276
-
1277
- eprintln ! ( "{}" , str :: from_utf8( & data. lock( ) . unwrap( ) ) . unwrap( ) ) ;
1278
1265
}
1279
1266
1280
- exit_on_err ( ) ;
1267
+ panic :: resume_unwind ( Box :: new ( errors :: FatalErrorMarker ) ) ;
1281
1268
}
1282
1269
}
1283
1270
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
-
1292
1271
#[ cfg( stage0) ]
1293
1272
pub fn diagnostics_registry ( ) -> errors:: registry:: Registry {
1294
1273
use errors:: registry:: Registry ;
0 commit comments