]> git.lizzy.rs Git - rust.git/blob - src/libstd/sys_common/util.rs
Rollup merge of #68093 - GuillaumeGomez:fix-deref-impl-typedef, r=oli-obk
[rust.git] / src / libstd / sys_common / util.rs
1 use crate::fmt;
2 use crate::io::prelude::*;
3 use crate::sys::stdio::panic_output;
4 use crate::thread;
5
6 pub fn dumb_print(args: fmt::Arguments<'_>) {
7     if let Some(mut out) = panic_output() {
8         let _ = out.write_fmt(args);
9     }
10 }
11
12 // Other platforms should use the appropriate platform-specific mechanism for
13 // aborting the process.  If no platform-specific mechanism is available,
14 // crate::intrinsics::abort() may be used instead.  The above implementations cover
15 // all targets currently supported by libstd.
16
17 pub fn abort(args: fmt::Arguments<'_>) -> ! {
18     dumb_print(format_args!("fatal runtime error: {}\n", args));
19     unsafe {
20         crate::sys::abort_internal();
21     }
22 }
23
24 #[allow(dead_code)] // stack overflow detection not enabled on all platforms
25 pub unsafe fn report_overflow() {
26     dumb_print(format_args!(
27         "\nthread '{}' has overflowed its stack\n",
28         thread::current().name().unwrap_or("<unknown>")
29     ));
30 }