Rollup merge of #99573 - tbodt:stabilize-backtrace, r=yaahc
Stabilize backtrace This PR stabilizes the std::backtrace module. As of #99431, the std::Error::backtrace item has been removed, and so the rest of the backtrace feature is set to be stabilized. Previous discussion can be found in #72981, #3156. Stabilized API summary: ```rust pub mod std { pub mod backtrace { pub struct Backtrace { } pub enum BacktraceStatus { Unsupported, Disabled, Captured, } impl fmt::Debug for Backtrace {} impl Backtrace { pub fn capture() -> Backtrace; pub fn force_capture() -> Backtrace; pub const fn disabled() -> Backtrace; pub fn status(&self) -> BacktraceStatus; } impl fmt::Display for Backtrace {} } } ``` `@yaahc`
This commit is contained in:
commit
e10f924e27
7 changed files with 11 additions and 15 deletions
|
@ -4,7 +4,6 @@
|
||||||
|
|
||||||
#![doc(html_root_url = "https://doc.rust-lang.org/nightly/nightly-rustc/")]
|
#![doc(html_root_url = "https://doc.rust-lang.org/nightly/nightly-rustc/")]
|
||||||
#![feature(drain_filter)]
|
#![feature(drain_filter)]
|
||||||
#![feature(backtrace)]
|
|
||||||
#![feature(if_let_guard)]
|
#![feature(if_let_guard)]
|
||||||
#![cfg_attr(bootstrap, feature(let_chains))]
|
#![cfg_attr(bootstrap, feature(let_chains))]
|
||||||
#![feature(let_else)]
|
#![feature(let_else)]
|
||||||
|
|
|
@ -26,7 +26,6 @@
|
||||||
#![feature(allocator_api)]
|
#![feature(allocator_api)]
|
||||||
#![feature(array_windows)]
|
#![feature(array_windows)]
|
||||||
#![feature(assert_matches)]
|
#![feature(assert_matches)]
|
||||||
#![feature(backtrace)]
|
|
||||||
#![feature(box_patterns)]
|
#![feature(box_patterns)]
|
||||||
#![feature(core_intrinsics)]
|
#![feature(core_intrinsics)]
|
||||||
#![feature(discriminant_kind)]
|
#![feature(discriminant_kind)]
|
||||||
|
|
|
@ -9,12 +9,6 @@
|
||||||
//! implementing `std::error::Error`) to get a causal chain of where an error
|
//! implementing `std::error::Error`) to get a causal chain of where an error
|
||||||
//! was generated.
|
//! was generated.
|
||||||
//!
|
//!
|
||||||
//! > **Note**: this module is unstable and is designed in [RFC 2504], and you
|
|
||||||
//! > can learn more about its status in the [tracking issue].
|
|
||||||
//!
|
|
||||||
//! [RFC 2504]: https://github.com/rust-lang/rfcs/blob/master/text/2504-fix-error.md
|
|
||||||
//! [tracking issue]: https://github.com/rust-lang/rust/issues/53487
|
|
||||||
//!
|
|
||||||
//! ## Accuracy
|
//! ## Accuracy
|
||||||
//!
|
//!
|
||||||
//! Backtraces are attempted to be as accurate as possible, but no guarantees
|
//! Backtraces are attempted to be as accurate as possible, but no guarantees
|
||||||
|
@ -64,7 +58,7 @@
|
||||||
//! `RUST_LIB_BACKTRACE` or `RUST_BACKTRACE` at runtime might not actually change
|
//! `RUST_LIB_BACKTRACE` or `RUST_BACKTRACE` at runtime might not actually change
|
||||||
//! how backtraces are captured.
|
//! how backtraces are captured.
|
||||||
|
|
||||||
#![unstable(feature = "backtrace", issue = "53487")]
|
#![stable(feature = "backtrace", since = "1.65.0")]
|
||||||
|
|
||||||
#[cfg(test)]
|
#[cfg(test)]
|
||||||
mod tests;
|
mod tests;
|
||||||
|
@ -110,6 +104,7 @@ use crate::vec::Vec;
|
||||||
/// previous point in time. In some instances the `Backtrace` type may
|
/// previous point in time. In some instances the `Backtrace` type may
|
||||||
/// internally be empty due to configuration. For more information see
|
/// internally be empty due to configuration. For more information see
|
||||||
/// `Backtrace::capture`.
|
/// `Backtrace::capture`.
|
||||||
|
#[stable(feature = "backtrace", since = "1.65.0")]
|
||||||
#[must_use]
|
#[must_use]
|
||||||
pub struct Backtrace {
|
pub struct Backtrace {
|
||||||
inner: Inner,
|
inner: Inner,
|
||||||
|
@ -117,6 +112,7 @@ pub struct Backtrace {
|
||||||
|
|
||||||
/// The current status of a backtrace, indicating whether it was captured or
|
/// The current status of a backtrace, indicating whether it was captured or
|
||||||
/// whether it is empty for some other reason.
|
/// whether it is empty for some other reason.
|
||||||
|
#[stable(feature = "backtrace", since = "1.65.0")]
|
||||||
#[non_exhaustive]
|
#[non_exhaustive]
|
||||||
#[derive(Debug, PartialEq, Eq)]
|
#[derive(Debug, PartialEq, Eq)]
|
||||||
pub enum BacktraceStatus {
|
pub enum BacktraceStatus {
|
||||||
|
@ -174,6 +170,7 @@ enum BytesOrWide {
|
||||||
Wide(Vec<u16>),
|
Wide(Vec<u16>),
|
||||||
}
|
}
|
||||||
|
|
||||||
|
#[stable(feature = "backtrace", since = "1.65.0")]
|
||||||
impl fmt::Debug for Backtrace {
|
impl fmt::Debug for Backtrace {
|
||||||
fn fmt(&self, fmt: &mut fmt::Formatter<'_>) -> fmt::Result {
|
fn fmt(&self, fmt: &mut fmt::Formatter<'_>) -> fmt::Result {
|
||||||
let capture = match &self.inner {
|
let capture = match &self.inner {
|
||||||
|
@ -200,6 +197,7 @@ impl fmt::Debug for Backtrace {
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
#[unstable(feature = "backtrace_frames", issue = "79676")]
|
||||||
impl fmt::Debug for BacktraceFrame {
|
impl fmt::Debug for BacktraceFrame {
|
||||||
fn fmt(&self, fmt: &mut fmt::Formatter<'_>) -> fmt::Result {
|
fn fmt(&self, fmt: &mut fmt::Formatter<'_>) -> fmt::Result {
|
||||||
let mut dbg = fmt.debug_list();
|
let mut dbg = fmt.debug_list();
|
||||||
|
@ -288,6 +286,7 @@ impl Backtrace {
|
||||||
///
|
///
|
||||||
/// To forcibly capture a backtrace regardless of environment variables, use
|
/// To forcibly capture a backtrace regardless of environment variables, use
|
||||||
/// the `Backtrace::force_capture` function.
|
/// the `Backtrace::force_capture` function.
|
||||||
|
#[stable(feature = "backtrace", since = "1.65.0")]
|
||||||
#[inline(never)] // want to make sure there's a frame here to remove
|
#[inline(never)] // want to make sure there's a frame here to remove
|
||||||
pub fn capture() -> Backtrace {
|
pub fn capture() -> Backtrace {
|
||||||
if !Backtrace::enabled() {
|
if !Backtrace::enabled() {
|
||||||
|
@ -306,6 +305,7 @@ impl Backtrace {
|
||||||
/// Note that capturing a backtrace can be an expensive operation on some
|
/// Note that capturing a backtrace can be an expensive operation on some
|
||||||
/// platforms, so this should be used with caution in performance-sensitive
|
/// platforms, so this should be used with caution in performance-sensitive
|
||||||
/// parts of code.
|
/// parts of code.
|
||||||
|
#[stable(feature = "backtrace", since = "1.65.0")]
|
||||||
#[inline(never)] // want to make sure there's a frame here to remove
|
#[inline(never)] // want to make sure there's a frame here to remove
|
||||||
pub fn force_capture() -> Backtrace {
|
pub fn force_capture() -> Backtrace {
|
||||||
Backtrace::create(Backtrace::force_capture as usize)
|
Backtrace::create(Backtrace::force_capture as usize)
|
||||||
|
@ -313,6 +313,8 @@ impl Backtrace {
|
||||||
|
|
||||||
/// Forcibly captures a disabled backtrace, regardless of environment
|
/// Forcibly captures a disabled backtrace, regardless of environment
|
||||||
/// variable configuration.
|
/// variable configuration.
|
||||||
|
#[stable(feature = "backtrace", since = "1.65.0")]
|
||||||
|
#[rustc_const_stable(feature = "backtrace", since = "1.65.0")]
|
||||||
pub const fn disabled() -> Backtrace {
|
pub const fn disabled() -> Backtrace {
|
||||||
Backtrace { inner: Inner::Disabled }
|
Backtrace { inner: Inner::Disabled }
|
||||||
}
|
}
|
||||||
|
@ -356,6 +358,7 @@ impl Backtrace {
|
||||||
/// Returns the status of this backtrace, indicating whether this backtrace
|
/// Returns the status of this backtrace, indicating whether this backtrace
|
||||||
/// request was unsupported, disabled, or a stack trace was actually
|
/// request was unsupported, disabled, or a stack trace was actually
|
||||||
/// captured.
|
/// captured.
|
||||||
|
#[stable(feature = "backtrace", since = "1.65.0")]
|
||||||
#[must_use]
|
#[must_use]
|
||||||
pub fn status(&self) -> BacktraceStatus {
|
pub fn status(&self) -> BacktraceStatus {
|
||||||
match self.inner {
|
match self.inner {
|
||||||
|
@ -375,6 +378,7 @@ impl<'a> Backtrace {
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
#[stable(feature = "backtrace", since = "1.65.0")]
|
||||||
impl fmt::Display for Backtrace {
|
impl fmt::Display for Backtrace {
|
||||||
fn fmt(&self, fmt: &mut fmt::Formatter<'_>) -> fmt::Result {
|
fn fmt(&self, fmt: &mut fmt::Formatter<'_>) -> fmt::Result {
|
||||||
let capture = match &self.inner {
|
let capture = match &self.inner {
|
||||||
|
|
|
@ -1454,7 +1454,6 @@ impl<E> Report<E> {
|
||||||
///
|
///
|
||||||
/// ```rust
|
/// ```rust
|
||||||
/// #![feature(error_reporter)]
|
/// #![feature(error_reporter)]
|
||||||
/// #![feature(backtrace)]
|
|
||||||
/// #![feature(provide_any)]
|
/// #![feature(provide_any)]
|
||||||
/// #![feature(error_generic_member_access)]
|
/// #![feature(error_generic_member_access)]
|
||||||
/// # use std::error::Error;
|
/// # use std::error::Error;
|
||||||
|
|
|
@ -1,6 +1,5 @@
|
||||||
// run-pass
|
// run-pass
|
||||||
|
|
||||||
#![feature(backtrace)]
|
|
||||||
#[derive(Clone, Copy)]
|
#[derive(Clone, Copy)]
|
||||||
struct Foo {
|
struct Foo {
|
||||||
array: [u64; 10240],
|
array: [u64; 10240],
|
||||||
|
|
|
@ -4,8 +4,6 @@
|
||||||
// compile-flags:-g -Csplit-debuginfo=unpacked
|
// compile-flags:-g -Csplit-debuginfo=unpacked
|
||||||
// only-macos
|
// only-macos
|
||||||
|
|
||||||
#![feature(backtrace)]
|
|
||||||
|
|
||||||
use std::process::Command;
|
use std::process::Command;
|
||||||
use std::str;
|
use std::str;
|
||||||
|
|
||||||
|
|
|
@ -7,8 +7,6 @@
|
||||||
// compile-flags:-g
|
// compile-flags:-g
|
||||||
// compile-flags:-Cstrip=none
|
// compile-flags:-Cstrip=none
|
||||||
|
|
||||||
#![feature(backtrace)]
|
|
||||||
|
|
||||||
use std::env;
|
use std::env;
|
||||||
use std::process::Command;
|
use std::process::Command;
|
||||||
use std::str;
|
use std::str;
|
||||||
|
|
Loading…
Add table
Add a link
Reference in a new issue