Skip to content

Commit 4d45f69

Browse files
committed
start PR over again
1 parent b81f581 commit 4d45f69

File tree

4 files changed

+55
-3
lines changed

4 files changed

+55
-3
lines changed

Diff for: library/core/src/backtrace.rs

+46
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,46 @@
1+
//! hi
2+
#![unstable(feature = "core_backtrace", issue = "74465")]
3+
use crate::fmt;
4+
5+
// perma(?)-unstable
6+
#[unstable(feature = "core_backtrace", issue = "74465")]
7+
///
8+
pub trait RawBacktraceImpl: fmt::Debug + fmt::Display + 'static {
9+
///
10+
unsafe fn drop_and_free(self: *mut Self);
11+
}
12+
13+
#[unstable(feature = "core_backtrace", issue = "74465")]
14+
///
15+
pub struct Backtrace {
16+
inner: *mut dyn RawBacktraceImpl,
17+
}
18+
19+
#[unstable(feature = "core_backtrace", issue = "74465")]
20+
unsafe impl Send for Backtrace {}
21+
22+
#[unstable(feature = "core_backtrace", issue = "74465")]
23+
unsafe impl Sync for Backtrace {}
24+
25+
#[unstable(feature = "core_backtrace", issue = "74465")]
26+
impl Drop for Backtrace {
27+
fn drop(&mut self) {
28+
unsafe { RawBacktraceImpl::drop_and_free(self.inner) }
29+
}
30+
}
31+
32+
#[unstable(feature = "core_backtrace", issue = "74465")]
33+
impl fmt::Debug for Backtrace {
34+
fn fmt(&self, fmt: &mut fmt::Formatter<'_>) -> fmt::Result {
35+
let imp: &dyn RawBacktraceImpl = unsafe { &*self.inner };
36+
fmt::Debug::fmt(imp, fmt)
37+
}
38+
}
39+
40+
#[unstable(feature = "core_backtrace", issue = "74465")]
41+
impl fmt::Display for Backtrace {
42+
fn fmt(&self, fmt: &mut fmt::Formatter<'_>) -> fmt::Result {
43+
let imp: &dyn RawBacktraceImpl = unsafe { &*self.inner };
44+
fmt::Display::fmt(imp, fmt)
45+
}
46+
}

Diff for: library/core/src/lib.rs

+1
Original file line numberDiff line numberDiff line change
@@ -241,6 +241,7 @@ pub mod ops;
241241
pub mod any;
242242
pub mod array;
243243
pub mod ascii;
244+
pub mod backtrace;
244245
pub mod cell;
245246
pub mod char;
246247
pub mod ffi;

Diff for: library/std/src/backtrace.rs

+7-3
Original file line numberDiff line numberDiff line change
@@ -104,16 +104,20 @@ use crate::sync::Once;
104104
use crate::sys_common::backtrace::{lock, output_filename};
105105
use crate::vec::Vec;
106106

107+
pub use core::backtrace::Backtrace;
108+
107109
/// A captured OS thread stack backtrace.
108110
///
109111
/// This type represents a stack backtrace for an OS thread captured at a
110112
/// previous point in time. In some instances the `Backtrace` type may
111113
/// internally be empty due to configuration. For more information see
112114
/// `Backtrace::capture`.
113-
pub struct Backtrace {
115+
struct BacktraceImpl {
114116
inner: Inner,
115117
}
116118

119+
impl core::backtrace::RawBacktraceImpl for BacktraceImpl {}
120+
117121
/// The current status of a backtrace, indicating whether it was captured or
118122
/// whether it is empty for some other reason.
119123
#[non_exhaustive]
@@ -173,7 +177,7 @@ enum BytesOrWide {
173177
Wide(Vec<u16>),
174178
}
175179

176-
impl fmt::Debug for Backtrace {
180+
impl fmt::Debug for BacktraceImpl {
177181
fn fmt(&self, fmt: &mut fmt::Formatter<'_>) -> fmt::Result {
178182
let capture = match &self.inner {
179183
Inner::Unsupported => return fmt.write_str("<unsupported>"),
@@ -372,7 +376,7 @@ impl<'a> Backtrace {
372376
}
373377
}
374378

375-
impl fmt::Display for Backtrace {
379+
impl fmt::Display for BacktraceImpl {
376380
fn fmt(&self, fmt: &mut fmt::Formatter<'_>) -> fmt::Result {
377381
let capture = match &self.inner {
378382
Inner::Unsupported => return fmt.write_str("unsupported backtrace"),

Diff for: library/std/src/lib.rs

+1
Original file line numberDiff line numberDiff line change
@@ -249,6 +249,7 @@
249249
#![feature(const_raw_ptr_deref)]
250250
#![feature(const_ipv4)]
251251
#![feature(container_error_extra)]
252+
#![feature(core_backtrace)]
252253
#![feature(core_intrinsics)]
253254
#![feature(custom_test_frameworks)]
254255
#![feature(decl_macro)]

0 commit comments

Comments
 (0)