1
Fork 0

Replace sys_common::util::dumb_print with rterr!

This commit is contained in:
Christiaan Dirkx 2021-04-29 16:10:32 +02:00
parent 236705f3c3
commit 6145051eee
4 changed files with 6 additions and 18 deletions

View file

@ -63,8 +63,6 @@ use core::ptr::NonNull;
use core::sync::atomic::{AtomicPtr, Ordering};
use core::{mem, ptr};
use crate::sys_common::util::dumb_print;
#[stable(feature = "alloc_module", since = "1.28.0")]
#[doc(inline)]
pub use alloc_crate::alloc::*;
@ -317,7 +315,7 @@ pub fn take_alloc_error_hook() -> fn(Layout) {
}
fn default_alloc_error_hook(layout: Layout) {
dumb_print(format_args!("memory allocation of {} bytes failed\n", layout.size()));
rterr!("memory allocation of {} bytes failed\n", layout.size());
}
#[cfg(not(test))]

View file

@ -20,7 +20,7 @@ use crate::sync::atomic::{AtomicBool, Ordering};
use crate::sys::stdio::panic_output;
use crate::sys_common::backtrace::{self, RustBacktrace};
use crate::sys_common::rwlock::RWLock;
use crate::sys_common::{thread_info, util};
use crate::sys_common::thread_info;
use crate::thread;
#[cfg(not(test))]
@ -596,15 +596,15 @@ fn rust_panic_with_hook(
if panics > 2 {
// Don't try to print the message in this case
// - perhaps that is causing the recursive panics.
util::dumb_print(format_args!("thread panicked while processing panic. aborting.\n"));
rterr!("thread panicked while processing panic. aborting.\n");
} else {
// Unfortunately, this does not print a backtrace, because creating
// a `Backtrace` will allocate, which we must to avoid here.
let panicinfo = PanicInfo::internal_constructor(message, location);
util::dumb_print(format_args!(
rterr!(
"{}\npanicked after panic::always_abort(), aborting.\n",
panicinfo
));
);
}
intrinsics::abort()
}
@ -637,7 +637,7 @@ fn rust_panic_with_hook(
// have limited options. Currently our preference is to
// just abort. In the future we may consider resuming
// unwinding or otherwise exiting the thread cleanly.
util::dumb_print(format_args!("thread panicked while panicking. aborting.\n"));
rterr!("thread panicked while panicking. aborting.\n");
intrinsics::abort()
}

View file

@ -40,7 +40,6 @@ pub mod thread_info;
pub mod thread_local_dtor;
pub mod thread_local_key;
pub mod thread_parker;
pub mod util;
pub mod wtf8;
cfg_if::cfg_if! {

View file

@ -1,9 +0,0 @@
use crate::fmt;
use crate::io::prelude::*;
use crate::sys::stdio::panic_output;
pub fn dumb_print(args: fmt::Arguments<'_>) {
if let Some(mut out) = panic_output() {
let _ = out.write_fmt(args);
}
}