From 5eeff3f0733c83be9e0406874e92adf24a5cf2b6 Mon Sep 17 00:00:00 2001 From: bjorn3 Date: Fri, 25 Jun 2021 12:58:21 +0200 Subject: Remove Config::stderr 1. It captured stdout and not stderr 2. It isn't used anywhere 3. All error messages should go to the DiagnosticOutput instead 4. It modifies thread local state --- compiler/rustc_interface/src/interface.rs | 8 +------- compiler/rustc_interface/src/util.rs | 17 +++-------------- 2 files changed, 4 insertions(+), 21 deletions(-) (limited to 'compiler/rustc_interface') diff --git a/compiler/rustc_interface/src/interface.rs b/compiler/rustc_interface/src/interface.rs index 8bd24487b78..9a588b55393 100644 --- a/compiler/rustc_interface/src/interface.rs +++ b/compiler/rustc_interface/src/interface.rs @@ -21,7 +21,6 @@ use rustc_session::{DiagnosticOutput, Session}; use rustc_span::source_map::{FileLoader, FileName}; use std::path::PathBuf; use std::result; -use std::sync::{Arc, Mutex}; pub type Result = result::Result; @@ -155,9 +154,6 @@ pub struct Config { pub file_loader: Option>, pub diagnostic_output: DiagnosticOutput, - /// Set to capture stderr output during compiler execution - pub stderr: Option>>>, - pub lint_caps: FxHashMap, /// This is a callback from the driver that is called when [`ParseSess`] is created. @@ -237,13 +233,11 @@ pub fn create_compiler_and_run(config: Config, f: impl FnOnce(&Compiler) -> R }) } -pub fn run_compiler(mut config: Config, f: impl FnOnce(&Compiler) -> R + Send) -> R { +pub fn run_compiler(config: Config, f: impl FnOnce(&Compiler) -> R + Send) -> R { tracing::trace!("run_compiler"); - let stderr = config.stderr.take(); util::run_in_thread_pool_with_globals( config.opts.edition, config.opts.debugging_opts.threads, - &stderr, || create_compiler_and_run(config, f), ) } diff --git a/compiler/rustc_interface/src/util.rs b/compiler/rustc_interface/src/util.rs index d206f2644e0..700710c82c9 100644 --- a/compiler/rustc_interface/src/util.rs +++ b/compiler/rustc_interface/src/util.rs @@ -27,7 +27,6 @@ use rustc_span::symbol::{sym, Symbol}; use smallvec::SmallVec; use std::env; use std::env::consts::{DLL_PREFIX, DLL_SUFFIX}; -use std::io; use std::lazy::SyncOnceCell; use std::mem; use std::ops::DerefMut; @@ -35,7 +34,6 @@ use std::ops::DerefMut; use std::panic; use std::path::{Path, PathBuf}; use std::sync::atomic::{AtomicBool, Ordering}; -use std::sync::{Arc, Mutex}; use std::thread; use tracing::info; @@ -131,7 +129,6 @@ fn scoped_thread R + Send, R: Send>(cfg: thread::Builder, f: F) - pub fn run_in_thread_pool_with_globals R + Send, R: Send>( edition: Edition, _threads: usize, - stderr: &Option>>>, f: F, ) -> R { let mut cfg = thread::Builder::new().name("rustc".to_string()); @@ -140,12 +137,7 @@ pub fn run_in_thread_pool_with_globals R + Send, R: Send>( cfg = cfg.stack_size(size); } - let main_handler = move || { - rustc_span::create_session_globals_then(edition, || { - io::set_output_capture(stderr.clone()); - f() - }) - }; + let main_handler = move || rustc_span::create_session_globals_then(edition, f); scoped_thread(cfg, main_handler) } @@ -177,7 +169,6 @@ unsafe fn handle_deadlock() { pub fn run_in_thread_pool_with_globals R + Send, R: Send>( edition: Edition, threads: usize, - stderr: &Option>>>, f: F, ) -> R { let mut config = rayon::ThreadPoolBuilder::new() @@ -199,10 +190,7 @@ pub fn run_in_thread_pool_with_globals R + Send, R: Send>( // the thread local rustc uses. `session_globals` is captured and set // on the new threads. let main_handler = move |thread: rayon::ThreadBuilder| { - rustc_span::set_session_globals_then(session_globals, || { - io::set_output_capture(stderr.clone()); - thread.run() - }) + rustc_span::set_session_globals_then(session_globals, || thread.run()) }; config.build_scoped(main_handler, with_pool).unwrap() @@ -339,6 +327,7 @@ fn sysroot_candidates() -> Vec { #[cfg(windows)] fn current_dll_path() -> Option { use std::ffi::OsString; + use std::io; use std::os::windows::prelude::*; use std::ptr; -- cgit 1.4.1-3-g733a5