From 89b578450c9acc08a95df656890a6cf71481833b Mon Sep 17 00:00:00 2001 From: joboet Date: Sun, 16 Jun 2024 13:14:01 +0200 Subject: [PATCH] std: move `sys_common::backtrace` to `sys` --- std/src/backtrace.rs | 2 +- std/src/error.rs | 2 +- std/src/panicking.rs | 6 +++--- std/src/rt.rs | 2 +- std/src/{sys_common => sys}/backtrace.rs | 4 ++-- std/src/sys/mod.rs | 1 + std/src/sys_common/mod.rs | 1 - std/src/thread/mod.rs | 2 +- 8 files changed, 10 insertions(+), 10 deletions(-) rename std/src/{sys_common => sys}/backtrace.rs (98%) diff --git a/std/src/backtrace.rs b/std/src/backtrace.rs index e3e0cde8afead..4d376753cb6d2 100644 --- a/std/src/backtrace.rs +++ b/std/src/backtrace.rs @@ -95,7 +95,7 @@ use crate::fmt; use crate::panic::UnwindSafe; use crate::sync::atomic::{AtomicU8, Ordering::Relaxed}; use crate::sync::LazyLock; -use crate::sys_common::backtrace::{lock, output_filename, set_image_base}; +use crate::sys::backtrace::{lock, output_filename, set_image_base}; /// A captured OS thread stack backtrace. /// diff --git a/std/src/error.rs b/std/src/error.rs index b240e4e2c45be..87aad8f764bd0 100644 --- a/std/src/error.rs +++ b/std/src/error.rs @@ -429,7 +429,7 @@ impl Report { /// 1: rust_out::main::_doctest_main_src_error_rs_1158_0 /// 2: rust_out::main /// 3: core::ops::function::FnOnce::call_once - /// 4: std::sys_common::backtrace::__rust_begin_short_backtrace + /// 4: std::sys::backtrace::__rust_begin_short_backtrace /// 5: std::rt::lang_start::{{closure}} /// 6: std::panicking::try /// 7: std::rt::lang_start_internal diff --git a/std/src/panicking.rs b/std/src/panicking.rs index 8fd8134c11147..2bb5ea28b181c 100644 --- a/std/src/panicking.rs +++ b/std/src/panicking.rs @@ -19,8 +19,8 @@ use crate::mem::{self, ManuallyDrop}; use crate::process; use crate::sync::atomic::{AtomicBool, Ordering}; use crate::sync::{PoisonError, RwLock}; +use crate::sys::backtrace; use crate::sys::stdio::panic_output; -use crate::sys_common::backtrace; use crate::thread; #[cfg(not(test))] @@ -655,7 +655,7 @@ pub fn begin_panic_handler(info: &core::panic::PanicInfo<'_>) -> ! { let loc = info.location().unwrap(); // The current implementation always returns Some let msg = info.message(); - crate::sys_common::backtrace::__rust_end_short_backtrace(move || { + crate::sys::backtrace::__rust_end_short_backtrace(move || { if let Some(s) = msg.as_str() { rust_panic_with_hook( &mut StaticStrPayload(s), @@ -727,7 +727,7 @@ pub const fn begin_panic(msg: M) -> ! { } let loc = Location::caller(); - crate::sys_common::backtrace::__rust_end_short_backtrace(move || { + crate::sys::backtrace::__rust_end_short_backtrace(move || { rust_panic_with_hook( &mut Payload { inner: Some(msg) }, loc, diff --git a/std/src/rt.rs b/std/src/rt.rs index 46f691d7b7504..b03fa1c01f266 100644 --- a/std/src/rt.rs +++ b/std/src/rt.rs @@ -156,7 +156,7 @@ fn lang_start( sigpipe: u8, ) -> isize { let Ok(v) = lang_start_internal( - &move || crate::sys_common::backtrace::__rust_begin_short_backtrace(main).report().to_i32(), + &move || crate::sys::backtrace::__rust_begin_short_backtrace(main).report().to_i32(), argc, argv, sigpipe, diff --git a/std/src/sys_common/backtrace.rs b/std/src/sys/backtrace.rs similarity index 98% rename from std/src/sys_common/backtrace.rs rename to std/src/sys/backtrace.rs index 67711dbd5bc75..0b2338fd7de9b 100644 --- a/std/src/sys_common/backtrace.rs +++ b/std/src/sys/backtrace.rs @@ -1,7 +1,7 @@ +//! Common code for printing backtraces. + use crate::backtrace_rs::{self, BacktraceFmt, BytesOrWideString, PrintFmt}; use crate::borrow::Cow; -/// Common code for printing the backtrace in the same way across the different -/// supported platforms. use crate::env; use crate::fmt; use crate::io; diff --git a/std/src/sys/mod.rs b/std/src/sys/mod.rs index 8f70cefc60121..8aa35c40fe052 100644 --- a/std/src/sys/mod.rs +++ b/std/src/sys/mod.rs @@ -5,6 +5,7 @@ mod pal; mod personality; +pub mod backtrace; pub mod cmath; pub mod os_str; pub mod path; diff --git a/std/src/sys_common/mod.rs b/std/src/sys_common/mod.rs index 3a38ba1100f01..200ea028a08ad 100644 --- a/std/src/sys_common/mod.rs +++ b/std/src/sys_common/mod.rs @@ -20,7 +20,6 @@ #[cfg(test)] mod tests; -pub mod backtrace; pub mod fs; pub mod io; pub mod lazy_box; diff --git a/std/src/thread/mod.rs b/std/src/thread/mod.rs index 83e27dfb746c2..c8ee365392f85 100644 --- a/std/src/thread/mod.rs +++ b/std/src/thread/mod.rs @@ -539,7 +539,7 @@ impl Builder { let f = f.into_inner(); set_current(their_thread); let try_result = panic::catch_unwind(panic::AssertUnwindSafe(|| { - crate::sys_common::backtrace::__rust_begin_short_backtrace(f) + crate::sys::backtrace::__rust_begin_short_backtrace(f) })); // SAFETY: `their_packet` as been built just above and moved by the // closure (it is an Arc<...>) and `my_packet` will be stored in the