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
This commit is contained in:
parent
9a60099cc4
commit
5eeff3f073
7 changed files with 4 additions and 26 deletions
|
@ -226,7 +226,6 @@ fn run_compiler(
|
||||||
output_dir: odir,
|
output_dir: odir,
|
||||||
file_loader,
|
file_loader,
|
||||||
diagnostic_output,
|
diagnostic_output,
|
||||||
stderr: None,
|
|
||||||
lint_caps: Default::default(),
|
lint_caps: Default::default(),
|
||||||
parse_sess_created: None,
|
parse_sess_created: None,
|
||||||
register_lints: None,
|
register_lints: None,
|
||||||
|
|
|
@ -21,7 +21,6 @@ use rustc_session::{DiagnosticOutput, Session};
|
||||||
use rustc_span::source_map::{FileLoader, FileName};
|
use rustc_span::source_map::{FileLoader, FileName};
|
||||||
use std::path::PathBuf;
|
use std::path::PathBuf;
|
||||||
use std::result;
|
use std::result;
|
||||||
use std::sync::{Arc, Mutex};
|
|
||||||
|
|
||||||
pub type Result<T> = result::Result<T, ErrorReported>;
|
pub type Result<T> = result::Result<T, ErrorReported>;
|
||||||
|
|
||||||
|
@ -155,9 +154,6 @@ pub struct Config {
|
||||||
pub file_loader: Option<Box<dyn FileLoader + Send + Sync>>,
|
pub file_loader: Option<Box<dyn FileLoader + Send + Sync>>,
|
||||||
pub diagnostic_output: DiagnosticOutput,
|
pub diagnostic_output: DiagnosticOutput,
|
||||||
|
|
||||||
/// Set to capture stderr output during compiler execution
|
|
||||||
pub stderr: Option<Arc<Mutex<Vec<u8>>>>,
|
|
||||||
|
|
||||||
pub lint_caps: FxHashMap<lint::LintId, lint::Level>,
|
pub lint_caps: FxHashMap<lint::LintId, lint::Level>,
|
||||||
|
|
||||||
/// This is a callback from the driver that is called when [`ParseSess`] is created.
|
/// This is a callback from the driver that is called when [`ParseSess`] is created.
|
||||||
|
@ -237,13 +233,11 @@ pub fn create_compiler_and_run<R>(config: Config, f: impl FnOnce(&Compiler) -> R
|
||||||
})
|
})
|
||||||
}
|
}
|
||||||
|
|
||||||
pub fn run_compiler<R: Send>(mut config: Config, f: impl FnOnce(&Compiler) -> R + Send) -> R {
|
pub fn run_compiler<R: Send>(config: Config, f: impl FnOnce(&Compiler) -> R + Send) -> R {
|
||||||
tracing::trace!("run_compiler");
|
tracing::trace!("run_compiler");
|
||||||
let stderr = config.stderr.take();
|
|
||||||
util::run_in_thread_pool_with_globals(
|
util::run_in_thread_pool_with_globals(
|
||||||
config.opts.edition,
|
config.opts.edition,
|
||||||
config.opts.debugging_opts.threads,
|
config.opts.debugging_opts.threads,
|
||||||
&stderr,
|
|
||||||
|| create_compiler_and_run(config, f),
|
|| create_compiler_and_run(config, f),
|
||||||
)
|
)
|
||||||
}
|
}
|
||||||
|
|
|
@ -27,7 +27,6 @@ use rustc_span::symbol::{sym, Symbol};
|
||||||
use smallvec::SmallVec;
|
use smallvec::SmallVec;
|
||||||
use std::env;
|
use std::env;
|
||||||
use std::env::consts::{DLL_PREFIX, DLL_SUFFIX};
|
use std::env::consts::{DLL_PREFIX, DLL_SUFFIX};
|
||||||
use std::io;
|
|
||||||
use std::lazy::SyncOnceCell;
|
use std::lazy::SyncOnceCell;
|
||||||
use std::mem;
|
use std::mem;
|
||||||
use std::ops::DerefMut;
|
use std::ops::DerefMut;
|
||||||
|
@ -35,7 +34,6 @@ use std::ops::DerefMut;
|
||||||
use std::panic;
|
use std::panic;
|
||||||
use std::path::{Path, PathBuf};
|
use std::path::{Path, PathBuf};
|
||||||
use std::sync::atomic::{AtomicBool, Ordering};
|
use std::sync::atomic::{AtomicBool, Ordering};
|
||||||
use std::sync::{Arc, Mutex};
|
|
||||||
use std::thread;
|
use std::thread;
|
||||||
use tracing::info;
|
use tracing::info;
|
||||||
|
|
||||||
|
@ -131,7 +129,6 @@ fn scoped_thread<F: FnOnce() -> R + Send, R: Send>(cfg: thread::Builder, f: F) -
|
||||||
pub fn run_in_thread_pool_with_globals<F: FnOnce() -> R + Send, R: Send>(
|
pub fn run_in_thread_pool_with_globals<F: FnOnce() -> R + Send, R: Send>(
|
||||||
edition: Edition,
|
edition: Edition,
|
||||||
_threads: usize,
|
_threads: usize,
|
||||||
stderr: &Option<Arc<Mutex<Vec<u8>>>>,
|
|
||||||
f: F,
|
f: F,
|
||||||
) -> R {
|
) -> R {
|
||||||
let mut cfg = thread::Builder::new().name("rustc".to_string());
|
let mut cfg = thread::Builder::new().name("rustc".to_string());
|
||||||
|
@ -140,12 +137,7 @@ pub fn run_in_thread_pool_with_globals<F: FnOnce() -> R + Send, R: Send>(
|
||||||
cfg = cfg.stack_size(size);
|
cfg = cfg.stack_size(size);
|
||||||
}
|
}
|
||||||
|
|
||||||
let main_handler = move || {
|
let main_handler = move || rustc_span::create_session_globals_then(edition, f);
|
||||||
rustc_span::create_session_globals_then(edition, || {
|
|
||||||
io::set_output_capture(stderr.clone());
|
|
||||||
f()
|
|
||||||
})
|
|
||||||
};
|
|
||||||
|
|
||||||
scoped_thread(cfg, main_handler)
|
scoped_thread(cfg, main_handler)
|
||||||
}
|
}
|
||||||
|
@ -177,7 +169,6 @@ unsafe fn handle_deadlock() {
|
||||||
pub fn run_in_thread_pool_with_globals<F: FnOnce() -> R + Send, R: Send>(
|
pub fn run_in_thread_pool_with_globals<F: FnOnce() -> R + Send, R: Send>(
|
||||||
edition: Edition,
|
edition: Edition,
|
||||||
threads: usize,
|
threads: usize,
|
||||||
stderr: &Option<Arc<Mutex<Vec<u8>>>>,
|
|
||||||
f: F,
|
f: F,
|
||||||
) -> R {
|
) -> R {
|
||||||
let mut config = rayon::ThreadPoolBuilder::new()
|
let mut config = rayon::ThreadPoolBuilder::new()
|
||||||
|
@ -199,10 +190,7 @@ pub fn run_in_thread_pool_with_globals<F: FnOnce() -> R + Send, R: Send>(
|
||||||
// the thread local rustc uses. `session_globals` is captured and set
|
// the thread local rustc uses. `session_globals` is captured and set
|
||||||
// on the new threads.
|
// on the new threads.
|
||||||
let main_handler = move |thread: rayon::ThreadBuilder| {
|
let main_handler = move |thread: rayon::ThreadBuilder| {
|
||||||
rustc_span::set_session_globals_then(session_globals, || {
|
rustc_span::set_session_globals_then(session_globals, || thread.run())
|
||||||
io::set_output_capture(stderr.clone());
|
|
||||||
thread.run()
|
|
||||||
})
|
|
||||||
};
|
};
|
||||||
|
|
||||||
config.build_scoped(main_handler, with_pool).unwrap()
|
config.build_scoped(main_handler, with_pool).unwrap()
|
||||||
|
@ -339,6 +327,7 @@ fn sysroot_candidates() -> Vec<PathBuf> {
|
||||||
#[cfg(windows)]
|
#[cfg(windows)]
|
||||||
fn current_dll_path() -> Option<PathBuf> {
|
fn current_dll_path() -> Option<PathBuf> {
|
||||||
use std::ffi::OsString;
|
use std::ffi::OsString;
|
||||||
|
use std::io;
|
||||||
use std::os::windows::prelude::*;
|
use std::os::windows::prelude::*;
|
||||||
use std::ptr;
|
use std::ptr;
|
||||||
|
|
||||||
|
|
|
@ -256,7 +256,6 @@ crate fn create_config(
|
||||||
output_dir: None,
|
output_dir: None,
|
||||||
file_loader: None,
|
file_loader: None,
|
||||||
diagnostic_output: DiagnosticOutput::Default,
|
diagnostic_output: DiagnosticOutput::Default,
|
||||||
stderr: None,
|
|
||||||
lint_caps,
|
lint_caps,
|
||||||
parse_sess_created: None,
|
parse_sess_created: None,
|
||||||
register_lints: Some(box crate::lint::register_lints),
|
register_lints: Some(box crate::lint::register_lints),
|
||||||
|
|
|
@ -97,7 +97,6 @@ crate fn run(options: RustdocOptions) -> Result<(), ErrorReported> {
|
||||||
output_dir: None,
|
output_dir: None,
|
||||||
file_loader: None,
|
file_loader: None,
|
||||||
diagnostic_output: DiagnosticOutput::Default,
|
diagnostic_output: DiagnosticOutput::Default,
|
||||||
stderr: None,
|
|
||||||
lint_caps,
|
lint_caps,
|
||||||
parse_sess_created: None,
|
parse_sess_created: None,
|
||||||
register_lints: Some(box crate::lint::register_lints),
|
register_lints: Some(box crate::lint::register_lints),
|
||||||
|
|
|
@ -691,7 +691,6 @@ fn main_args(at_args: &[String]) -> MainResult {
|
||||||
rustc_interface::util::run_in_thread_pool_with_globals(
|
rustc_interface::util::run_in_thread_pool_with_globals(
|
||||||
options.edition,
|
options.edition,
|
||||||
1, // this runs single-threaded, even in a parallel compiler
|
1, // this runs single-threaded, even in a parallel compiler
|
||||||
&None,
|
|
||||||
move || main_options(options),
|
move || main_options(options),
|
||||||
)
|
)
|
||||||
}
|
}
|
||||||
|
|
|
@ -55,7 +55,6 @@ fn compile(code: String, output: PathBuf, sysroot: PathBuf) {
|
||||||
output_dir: None,
|
output_dir: None,
|
||||||
file_loader: None,
|
file_loader: None,
|
||||||
diagnostic_output: DiagnosticOutput::Default,
|
diagnostic_output: DiagnosticOutput::Default,
|
||||||
stderr: None,
|
|
||||||
lint_caps: Default::default(),
|
lint_caps: Default::default(),
|
||||||
parse_sess_created: None,
|
parse_sess_created: None,
|
||||||
register_lints: None,
|
register_lints: None,
|
||||||
|
|
Loading…
Add table
Add a link
Reference in a new issue