Use Vec<u8> for LOCAL_STD{OUT,ERR} instead of dyn Write.

It was only ever used with Vec<u8> anyway. This simplifies some things.

- It no longer needs to be flushed, because that's a no-op anyway for
  a Vec<u8>.

- Writing to a Vec<u8> never fails.

- No #[cfg(test)] code is needed anymore to use `realstd` instead of
  `std`, because Vec comes from alloc, not std (like Write).
This commit is contained in:
Mara Bos 2020-11-03 21:44:21 +01:00
parent ccbce1d3b2
commit f534b75f05
5 changed files with 28 additions and 78 deletions

View file

@ -148,9 +148,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(stderr.clone()));
}
io::set_panic(stderr.clone());
f()
})
};
@ -188,9 +186,7 @@ pub fn setup_callbacks_and_run_in_thread_pool_with_globals<F: FnOnce() -> R + Se
// on the new threads.
let main_handler = move |thread: rayon::ThreadBuilder| {
rustc_span::SESSION_GLOBALS.set(session_globals, || {
if let Some(stderr) = stderr {
io::set_panic(Some(stderr.clone()));
}
io::set_panic(stderr.clone());
thread.run()
})
};