summary refs log tree commit diff
path: root/compiler/rustc_interface/src
diff options
context:
space:
mode:
authorMara Bos <m-ou.se@m-ou.se>2020-11-03 20:48:25 +0100
committerMara Bos <m-ou.se@m-ou.se>2020-11-10 21:57:05 +0100
commit72e96604c0115ee77b0817d8bb053bcfd4625b70 (patch)
treefc757f7d59d96f6ddab5dc313bf841e83b06727d /compiler/rustc_interface/src
parentcf9cf7c923eb01146971429044f216a3ca905e06 (diff)
downloadrust-72e96604c0115ee77b0817d8bb053bcfd4625b70.tar.gz
rust-72e96604c0115ee77b0817d8bb053bcfd4625b70.zip
Remove io::LocalOutput and use Arc<Mutex<dyn>> for local streams.
Diffstat (limited to 'compiler/rustc_interface/src')
-rw-r--r--compiler/rustc_interface/src/util.rs21
1 files changed, 3 insertions, 18 deletions
diff --git a/compiler/rustc_interface/src/util.rs b/compiler/rustc_interface/src/util.rs
index d9ec6d51cdf..d90fff3bae5 100644
--- a/compiler/rustc_interface/src/util.rs
+++ b/compiler/rustc_interface/src/util.rs
@@ -25,7 +25,7 @@ use rustc_span::symbol::{sym, Symbol};
 use smallvec::SmallVec;
 use std::env;
 use std::env::consts::{DLL_PREFIX, DLL_SUFFIX};
-use std::io::{self, Write};
+use std::io;
 use std::lazy::SyncOnceCell;
 use std::mem;
 use std::ops::DerefMut;
@@ -106,21 +106,6 @@ fn get_stack_size() -> Option<usize> {
     env::var_os("RUST_MIN_STACK").is_none().then_some(STACK_SIZE)
 }
 
-struct Sink(Arc<Mutex<Vec<u8>>>);
-impl Write for Sink {
-    fn write(&mut self, data: &[u8]) -> io::Result<usize> {
-        Write::write(&mut *self.0.lock().unwrap(), data)
-    }
-    fn flush(&mut self) -> io::Result<()> {
-        Ok(())
-    }
-}
-impl io::LocalOutput for Sink {
-    fn clone_box(&self) -> Box<dyn io::LocalOutput> {
-        Box::new(Self(self.0.clone()))
-    }
-}
-
 /// Like a `thread::Builder::spawn` followed by a `join()`, but avoids the need
 /// for `'static` bounds.
 #[cfg(not(parallel_compiler))]
@@ -164,7 +149,7 @@ pub fn setup_callbacks_and_run_in_thread_pool_with_globals<F: FnOnce() -> R + Se
     let main_handler = move || {
         rustc_span::with_session_globals(edition, || {
             if let Some(stderr) = stderr {
-                io::set_panic(Some(box Sink(stderr.clone())));
+                io::set_panic(Some(stderr.clone()));
             }
             f()
         })
@@ -204,7 +189,7 @@ pub fn setup_callbacks_and_run_in_thread_pool_with_globals<F: FnOnce() -> R + Se
             let main_handler = move |thread: rayon::ThreadBuilder| {
                 rustc_span::SESSION_GLOBALS.set(session_globals, || {
                     if let Some(stderr) = stderr {
-                        io::set_panic(Some(box Sink(stderr.clone())));
+                        io::set_panic(Some(stderr.clone()));
                     }
                     thread.run()
                 })