Skip to content

Commit 5eeff3f

Browse files
committed
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
1 parent 9a60099 commit 5eeff3f

File tree

7 files changed

+4
-26
lines changed

7 files changed

+4
-26
lines changed

compiler/rustc_driver/src/lib.rs

-1
Original file line numberDiff line numberDiff line change
@@ -226,7 +226,6 @@ fn run_compiler(
226226
output_dir: odir,
227227
file_loader,
228228
diagnostic_output,
229-
stderr: None,
230229
lint_caps: Default::default(),
231230
parse_sess_created: None,
232231
register_lints: None,

compiler/rustc_interface/src/interface.rs

+1-7
Original file line numberDiff line numberDiff line change
@@ -21,7 +21,6 @@ use rustc_session::{DiagnosticOutput, Session};
2121
use rustc_span::source_map::{FileLoader, FileName};
2222
use std::path::PathBuf;
2323
use std::result;
24-
use std::sync::{Arc, Mutex};
2524

2625
pub type Result<T> = result::Result<T, ErrorReported>;
2726

@@ -155,9 +154,6 @@ pub struct Config {
155154
pub file_loader: Option<Box<dyn FileLoader + Send + Sync>>,
156155
pub diagnostic_output: DiagnosticOutput,
157156

158-
/// Set to capture stderr output during compiler execution
159-
pub stderr: Option<Arc<Mutex<Vec<u8>>>>,
160-
161157
pub lint_caps: FxHashMap<lint::LintId, lint::Level>,
162158

163159
/// 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
237233
})
238234
}
239235

240-
pub fn run_compiler<R: Send>(mut config: Config, f: impl FnOnce(&Compiler) -> R + Send) -> R {
236+
pub fn run_compiler<R: Send>(config: Config, f: impl FnOnce(&Compiler) -> R + Send) -> R {
241237
tracing::trace!("run_compiler");
242-
let stderr = config.stderr.take();
243238
util::run_in_thread_pool_with_globals(
244239
config.opts.edition,
245240
config.opts.debugging_opts.threads,
246-
&stderr,
247241
|| create_compiler_and_run(config, f),
248242
)
249243
}

compiler/rustc_interface/src/util.rs

+3-14
Original file line numberDiff line numberDiff line change
@@ -27,15 +27,13 @@ use rustc_span::symbol::{sym, Symbol};
2727
use smallvec::SmallVec;
2828
use std::env;
2929
use std::env::consts::{DLL_PREFIX, DLL_SUFFIX};
30-
use std::io;
3130
use std::lazy::SyncOnceCell;
3231
use std::mem;
3332
use std::ops::DerefMut;
3433
#[cfg(not(parallel_compiler))]
3534
use std::panic;
3635
use std::path::{Path, PathBuf};
3736
use std::sync::atomic::{AtomicBool, Ordering};
38-
use std::sync::{Arc, Mutex};
3937
use std::thread;
4038
use tracing::info;
4139

@@ -131,7 +129,6 @@ fn scoped_thread<F: FnOnce() -> R + Send, R: Send>(cfg: thread::Builder, f: F) -
131129
pub fn run_in_thread_pool_with_globals<F: FnOnce() -> R + Send, R: Send>(
132130
edition: Edition,
133131
_threads: usize,
134-
stderr: &Option<Arc<Mutex<Vec<u8>>>>,
135132
f: F,
136133
) -> R {
137134
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>(
140137
cfg = cfg.stack_size(size);
141138
}
142139

143-
let main_handler = move || {
144-
rustc_span::create_session_globals_then(edition, || {
145-
io::set_output_capture(stderr.clone());
146-
f()
147-
})
148-
};
140+
let main_handler = move || rustc_span::create_session_globals_then(edition, f);
149141

150142
scoped_thread(cfg, main_handler)
151143
}
@@ -177,7 +169,6 @@ unsafe fn handle_deadlock() {
177169
pub fn run_in_thread_pool_with_globals<F: FnOnce() -> R + Send, R: Send>(
178170
edition: Edition,
179171
threads: usize,
180-
stderr: &Option<Arc<Mutex<Vec<u8>>>>,
181172
f: F,
182173
) -> R {
183174
let mut config = rayon::ThreadPoolBuilder::new()
@@ -199,10 +190,7 @@ pub fn run_in_thread_pool_with_globals<F: FnOnce() -> R + Send, R: Send>(
199190
// the thread local rustc uses. `session_globals` is captured and set
200191
// on the new threads.
201192
let main_handler = move |thread: rayon::ThreadBuilder| {
202-
rustc_span::set_session_globals_then(session_globals, || {
203-
io::set_output_capture(stderr.clone());
204-
thread.run()
205-
})
193+
rustc_span::set_session_globals_then(session_globals, || thread.run())
206194
};
207195

208196
config.build_scoped(main_handler, with_pool).unwrap()
@@ -339,6 +327,7 @@ fn sysroot_candidates() -> Vec<PathBuf> {
339327
#[cfg(windows)]
340328
fn current_dll_path() -> Option<PathBuf> {
341329
use std::ffi::OsString;
330+
use std::io;
342331
use std::os::windows::prelude::*;
343332
use std::ptr;
344333

src/librustdoc/core.rs

-1
Original file line numberDiff line numberDiff line change
@@ -256,7 +256,6 @@ crate fn create_config(
256256
output_dir: None,
257257
file_loader: None,
258258
diagnostic_output: DiagnosticOutput::Default,
259-
stderr: None,
260259
lint_caps,
261260
parse_sess_created: None,
262261
register_lints: Some(box crate::lint::register_lints),

src/librustdoc/doctest.rs

-1
Original file line numberDiff line numberDiff line change
@@ -97,7 +97,6 @@ crate fn run(options: RustdocOptions) -> Result<(), ErrorReported> {
9797
output_dir: None,
9898
file_loader: None,
9999
diagnostic_output: DiagnosticOutput::Default,
100-
stderr: None,
101100
lint_caps,
102101
parse_sess_created: None,
103102
register_lints: Some(box crate::lint::register_lints),

src/librustdoc/lib.rs

-1
Original file line numberDiff line numberDiff line change
@@ -691,7 +691,6 @@ fn main_args(at_args: &[String]) -> MainResult {
691691
rustc_interface::util::run_in_thread_pool_with_globals(
692692
options.edition,
693693
1, // this runs single-threaded, even in a parallel compiler
694-
&None,
695694
move || main_options(options),
696695
)
697696
}

src/test/run-make-fulldeps/issue-19371/foo.rs

-1
Original file line numberDiff line numberDiff line change
@@ -55,7 +55,6 @@ fn compile(code: String, output: PathBuf, sysroot: PathBuf) {
5555
output_dir: None,
5656
file_loader: None,
5757
diagnostic_output: DiagnosticOutput::Default,
58-
stderr: None,
5958
lint_caps: Default::default(),
6059
parse_sess_created: None,
6160
register_lints: None,

0 commit comments

Comments
 (0)