From 72e96604c0115ee77b0817d8bb053bcfd4625b70 Mon Sep 17 00:00:00 2001 From: Mara Bos Date: Tue, 3 Nov 2020 20:48:25 +0100 Subject: Remove io::LocalOutput and use Arc> for local streams. --- compiler/rustc_interface/src/util.rs | 21 +++------------------ 1 file changed, 3 insertions(+), 18 deletions(-) (limited to 'compiler/rustc_interface/src') 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 { env::var_os("RUST_MIN_STACK").is_none().then_some(STACK_SIZE) } -struct Sink(Arc>>); -impl Write for Sink { - fn write(&mut self, data: &[u8]) -> io::Result { - 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 { - 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 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 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() }) -- cgit 1.4.1-3-g733a5