@@ -232,40 +232,42 @@ fn run_test(test: &str, cratename: &str, filename: &FileName, line: usize,
232232 ..config:: basic_options ( ) . clone ( )
233233 } ;
234234
235- let ( libdir, outdir) = driver:: spawn_thread_pool ( sessopts, |sessopts| {
236- // Shuffle around a few input and output handles here. We're going to pass
237- // an explicit handle into rustc to collect output messages, but we also
238- // want to catch the error message that rustc prints when it fails.
239- //
240- // We take our thread-local stderr (likely set by the test runner) and replace
241- // it with a sink that is also passed to rustc itself. When this function
242- // returns the output of the sink is copied onto the output of our own thread.
243- //
244- // The basic idea is to not use a default Handler for rustc, and then also
245- // not print things by default to the actual stderr.
246- struct Sink ( Arc < Mutex < Vec < u8 > > > ) ;
247- impl Write for Sink {
248- fn write ( & mut self , data : & [ u8 ] ) -> io:: Result < usize > {
249- Write :: write ( & mut * self . 0 . lock ( ) . unwrap ( ) , data)
250- }
251- fn flush ( & mut self ) -> io:: Result < ( ) > { Ok ( ( ) ) }
235+ // Shuffle around a few input and output handles here. We're going to pass
236+ // an explicit handle into rustc to collect output messages, but we also
237+ // want to catch the error message that rustc prints when it fails.
238+ //
239+ // We take our thread-local stderr (likely set by the test runner) and replace
240+ // it with a sink that is also passed to rustc itself. When this function
241+ // returns the output of the sink is copied onto the output of our own thread.
242+ //
243+ // The basic idea is to not use a default Handler for rustc, and then also
244+ // not print things by default to the actual stderr.
245+ struct Sink ( Arc < Mutex < Vec < u8 > > > ) ;
246+ impl Write for Sink {
247+ fn write ( & mut self , data : & [ u8 ] ) -> io:: Result < usize > {
248+ Write :: write ( & mut * self . 0 . lock ( ) . unwrap ( ) , data)
252249 }
253- struct Bomb ( Arc < Mutex < Vec < u8 > > > , Box < Write +Send > ) ;
254- impl Drop for Bomb {
255- fn drop ( & mut self ) {
256- let _ = self . 1 . write_all ( & self . 0 . lock ( ) . unwrap ( ) ) ;
257- }
250+ fn flush ( & mut self ) -> io:: Result < ( ) > { Ok ( ( ) ) }
251+ }
252+ struct Bomb ( Arc < Mutex < Vec < u8 > > > , Box < Write +Send > ) ;
253+ impl Drop for Bomb {
254+ fn drop ( & mut self ) {
255+ let _ = self . 1 . write_all ( & self . 0 . lock ( ) . unwrap ( ) ) ;
258256 }
259- let data = Arc :: new ( Mutex :: new ( Vec :: new ( ) ) ) ;
257+ }
258+ let data = Arc :: new ( Mutex :: new ( Vec :: new ( ) ) ) ;
259+
260+ let old = io:: set_panic ( Some ( box Sink ( data. clone ( ) ) ) ) ;
261+ let _bomb = Bomb ( data. clone ( ) , old. unwrap_or ( box io:: stdout ( ) ) ) ;
262+
263+ let ( libdir, outdir, compile_result) = driver:: spawn_thread_pool ( sessopts, |sessopts| {
260264 let codemap = Lrc :: new ( CodeMap :: new_doctest (
261265 sessopts. file_path_mapping ( ) , filename. clone ( ) , line as isize - line_offset as isize
262266 ) ) ;
263267 let emitter = errors:: emitter:: EmitterWriter :: new ( box Sink ( data. clone ( ) ) ,
264268 Some ( codemap. clone ( ) ) ,
265269 false ,
266270 false ) ;
267- let old = io:: set_panic ( Some ( box Sink ( data. clone ( ) ) ) ) ;
268- let _bomb = Bomb ( data. clone ( ) , old. unwrap_or ( box io:: stdout ( ) ) ) ;
269271
270272 // Compile the code
271273 let diagnostic_handler = errors:: Handler :: with_emitter ( true , false , box emitter) ;
@@ -312,28 +314,28 @@ fn run_test(test: &str, cratename: &str, filename: &FileName, line: usize,
312314 Err ( _) | Ok ( Err ( CompileIncomplete :: Errored ( _) ) ) => Err ( ( ) )
313315 } ;
314316
315- match ( compile_result, compile_fail) {
316- ( Ok ( ( ) ) , true ) => {
317- panic ! ( "test compiled while it wasn't supposed to" )
318- }
319- ( Ok ( ( ) ) , false ) => { }
320- ( Err ( ( ) ) , true ) => {
321- if error_codes. len ( ) > 0 {
322- let out = String :: from_utf8 ( data. lock ( ) . unwrap ( ) . to_vec ( ) ) . unwrap ( ) ;
323- error_codes. retain ( |err| !out. contains ( err) ) ;
324- }
325- }
326- ( Err ( ( ) ) , false ) => {
327- panic ! ( "couldn't compile the test" )
317+ ( libdir, outdir, compile_result)
318+ } ) ;
319+
320+ match ( compile_result, compile_fail) {
321+ ( Ok ( ( ) ) , true ) => {
322+ panic ! ( "test compiled while it wasn't supposed to" )
323+ }
324+ ( Ok ( ( ) ) , false ) => { }
325+ ( Err ( ( ) ) , true ) => {
326+ if error_codes. len ( ) > 0 {
327+ let out = String :: from_utf8 ( data. lock ( ) . unwrap ( ) . to_vec ( ) ) . unwrap ( ) ;
328+ error_codes. retain ( |err| !out. contains ( err) ) ;
328329 }
329330 }
330-
331- if error_codes. len ( ) > 0 {
332- panic ! ( "Some expected error codes were not found: {:?}" , error_codes) ;
331+ ( Err ( ( ) ) , false ) => {
332+ panic ! ( "couldn't compile the test" )
333333 }
334+ }
334335
335- ( libdir, outdir)
336- } ) ;
336+ if error_codes. len ( ) > 0 {
337+ panic ! ( "Some expected error codes were not found: {:?}" , error_codes) ;
338+ }
337339
338340 if no_run { return }
339341
@@ -548,7 +550,7 @@ impl Collector {
548550 debug ! ( "Creating test {}: {}" , name, test) ;
549551 self . tests . push ( testing:: TestDescAndFn {
550552 desc : testing:: TestDesc {
551- name : testing:: DynTestName ( name) ,
553+ name : testing:: DynTestName ( name. clone ( ) ) ,
552554 ignore : should_ignore,
553555 // compiler failures are test failures
554556 should_panic : testing:: ShouldPanic :: No ,
@@ -558,7 +560,7 @@ impl Collector {
558560 let panic = io:: set_panic ( None ) ;
559561 let print = io:: set_print ( None ) ;
560562 match {
561- rustc_driver:: in_rustc_thread ( move || with_globals ( move || {
563+ rustc_driver:: in_named_rustc_thread ( name , move || with_globals ( move || {
562564 io:: set_panic ( panic) ;
563565 io:: set_print ( print) ;
564566 hygiene:: set_default_edition ( edition) ;
0 commit comments