From c655b81e8942ac0dd370618d324a308407b635dd Mon Sep 17 00:00:00 2001 From: Without Boats Date: Thu, 4 Jun 2020 14:32:49 +0200 Subject: [PATCH 1/5] Stabilize the backtrace feature. --- compiler/rustc_middle/src/lib.rs | 1 - library/std/src/backtrace.rs | 18 +++++++++++------- library/std/src/error.rs | 2 +- src/test/ui/std-backtrace.rs | 2 -- 4 files changed, 12 insertions(+), 11 deletions(-) diff --git a/compiler/rustc_middle/src/lib.rs b/compiler/rustc_middle/src/lib.rs index 6ae83a7f66750..0a6caeea79a70 100644 --- a/compiler/rustc_middle/src/lib.rs +++ b/compiler/rustc_middle/src/lib.rs @@ -25,7 +25,6 @@ #![doc(html_root_url = "https://doc.rust-lang.org/nightly/nightly-rustc/")] #![feature(array_windows)] #![feature(assoc_char_funcs)] -#![feature(backtrace)] #![feature(bool_to_option)] #![feature(box_patterns)] #![feature(box_syntax)] diff --git a/library/std/src/backtrace.rs b/library/std/src/backtrace.rs index 7e8e0a621e31c..62660dac66145 100644 --- a/library/std/src/backtrace.rs +++ b/library/std/src/backtrace.rs @@ -9,12 +9,6 @@ //! implementing `std::error::Error`) to get a causal chain of where an error //! 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 //! //! Backtraces are attempted to be as accurate as possible, but no guarantees @@ -64,7 +58,7 @@ //! `RUST_LIB_BACKTRACE` or `RUST_BACKTRACE` at runtime may not actually change //! how backtraces are captured. -#![unstable(feature = "backtrace", issue = "53487")] +#![stable(feature = "backtrace", since = "1.50.0")] #[cfg(test)] mod tests; @@ -109,6 +103,7 @@ use crate::vec::Vec; /// previous point in time. In some instances the `Backtrace` type may /// internally be empty due to configuration. For more information see /// `Backtrace::capture`. +#[stable(feature = "backtrace", since = "1.50.0")] pub struct Backtrace { inner: Inner, } @@ -117,15 +112,19 @@ pub struct Backtrace { /// whether it is empty for some other reason. #[non_exhaustive] #[derive(Debug, PartialEq, Eq)] +#[stable(feature = "backtrace", since = "1.50.0")] pub enum BacktraceStatus { /// Capturing a backtrace is not supported, likely because it's not /// implemented for the current platform. + #[stable(feature = "backtrace", since = "1.50.0")] Unsupported, /// Capturing a backtrace has been disabled through either the /// `RUST_LIB_BACKTRACE` or `RUST_BACKTRACE` environment variables. + #[stable(feature = "backtrace", since = "1.50.0")] Disabled, /// A backtrace has been captured and the `Backtrace` should print /// reasonable information when rendered. + #[stable(feature = "backtrace", since = "1.50.0")] Captured, } @@ -169,6 +168,7 @@ enum BytesOrWide { Wide(Vec), } +#[stable(feature = "backtrace", since = "1.50.0")] impl fmt::Debug for Backtrace { fn fmt(&self, fmt: &mut fmt::Formatter<'_>) -> fmt::Result { let mut capture = match &self.inner { @@ -276,6 +276,7 @@ impl Backtrace { /// /// To forcibly capture a backtrace regardless of environment variables, use /// the `Backtrace::force_capture` function. + #[stable(feature = "backtrace", since = "1.50.0")] #[inline(never)] // want to make sure there's a frame here to remove pub fn capture() -> Backtrace { if !Backtrace::enabled() { @@ -294,6 +295,7 @@ impl Backtrace { /// Note that capturing a backtrace can be an expensive operation on some /// platforms, so this should be used with caution in performance-sensitive /// parts of code. + #[stable(feature = "backtrace", since = "1.50.0")] #[inline(never)] // want to make sure there's a frame here to remove pub fn force_capture() -> Backtrace { Backtrace::create(Backtrace::force_capture as usize) @@ -344,6 +346,7 @@ impl Backtrace { /// Returns the status of this backtrace, indicating whether this backtrace /// request was unsupported, disabled, or a stack trace was actually /// captured. + #[stable(feature = "backtrace", since = "1.50.0")] pub fn status(&self) -> BacktraceStatus { match self.inner { Inner::Unsupported => BacktraceStatus::Unsupported, @@ -353,6 +356,7 @@ impl Backtrace { } } +#[stable(feature = "backtrace", since = "1.50.0")] impl fmt::Display for Backtrace { fn fmt(&self, fmt: &mut fmt::Formatter<'_>) -> fmt::Result { let mut capture = match &self.inner { diff --git a/library/std/src/error.rs b/library/std/src/error.rs index ca83c409822fc..5e3a9ba104e54 100644 --- a/library/std/src/error.rs +++ b/library/std/src/error.rs @@ -122,7 +122,7 @@ pub trait Error: Debug + Display { /// Note that not all errors contain a `Backtrace`. Also note that a /// `Backtrace` may actually be empty. For more information consult the /// `Backtrace` type itself. - #[unstable(feature = "backtrace", issue = "53487")] + #[stable(feature = "backtrace", since = "1.50.0")] fn backtrace(&self) -> Option<&Backtrace> { None } diff --git a/src/test/ui/std-backtrace.rs b/src/test/ui/std-backtrace.rs index b5e76666af1f8..fb1883fc654b1 100644 --- a/src/test/ui/std-backtrace.rs +++ b/src/test/ui/std-backtrace.rs @@ -6,8 +6,6 @@ // ignore-msvc see #62897 and `backtrace-debuginfo.rs` test // compile-flags:-g -#![feature(backtrace)] - use std::env; use std::process::Command; use std::str; From 2d661ef07501dc322eabe65784f1169cb948cbed Mon Sep 17 00:00:00 2001 From: Jakub Duchniewicz Date: Sat, 9 Jan 2021 16:32:57 +0100 Subject: [PATCH 2/5] Bump up version to 1.51. --- library/std/src/backtrace.rs | 22 +++++++++++----------- library/std/src/error.rs | 2 +- 2 files changed, 12 insertions(+), 12 deletions(-) diff --git a/library/std/src/backtrace.rs b/library/std/src/backtrace.rs index 62660dac66145..a8e7f8ae68be6 100644 --- a/library/std/src/backtrace.rs +++ b/library/std/src/backtrace.rs @@ -58,7 +58,7 @@ //! `RUST_LIB_BACKTRACE` or `RUST_BACKTRACE` at runtime may not actually change //! how backtraces are captured. -#![stable(feature = "backtrace", since = "1.50.0")] +#![stable(feature = "backtrace", since = "1.51.0")] #[cfg(test)] mod tests; @@ -103,7 +103,7 @@ use crate::vec::Vec; /// previous point in time. In some instances the `Backtrace` type may /// internally be empty due to configuration. For more information see /// `Backtrace::capture`. -#[stable(feature = "backtrace", since = "1.50.0")] +#[stable(feature = "backtrace", since = "1.51.0")] pub struct Backtrace { inner: Inner, } @@ -112,19 +112,19 @@ pub struct Backtrace { /// whether it is empty for some other reason. #[non_exhaustive] #[derive(Debug, PartialEq, Eq)] -#[stable(feature = "backtrace", since = "1.50.0")] +#[stable(feature = "backtrace", since = "1.51.0")] pub enum BacktraceStatus { /// Capturing a backtrace is not supported, likely because it's not /// implemented for the current platform. - #[stable(feature = "backtrace", since = "1.50.0")] + #[stable(feature = "backtrace", since = "1.51.0")] Unsupported, /// Capturing a backtrace has been disabled through either the /// `RUST_LIB_BACKTRACE` or `RUST_BACKTRACE` environment variables. - #[stable(feature = "backtrace", since = "1.50.0")] + #[stable(feature = "backtrace", since = "1.51.0")] Disabled, /// A backtrace has been captured and the `Backtrace` should print /// reasonable information when rendered. - #[stable(feature = "backtrace", since = "1.50.0")] + #[stable(feature = "backtrace", since = "1.51.0")] Captured, } @@ -168,7 +168,7 @@ enum BytesOrWide { Wide(Vec), } -#[stable(feature = "backtrace", since = "1.50.0")] +#[stable(feature = "backtrace", since = "1.51.0")] impl fmt::Debug for Backtrace { fn fmt(&self, fmt: &mut fmt::Formatter<'_>) -> fmt::Result { let mut capture = match &self.inner { @@ -276,7 +276,7 @@ impl Backtrace { /// /// To forcibly capture a backtrace regardless of environment variables, use /// the `Backtrace::force_capture` function. - #[stable(feature = "backtrace", since = "1.50.0")] + #[stable(feature = "backtrace", since = "1.51.0")] #[inline(never)] // want to make sure there's a frame here to remove pub fn capture() -> Backtrace { if !Backtrace::enabled() { @@ -295,7 +295,7 @@ impl Backtrace { /// Note that capturing a backtrace can be an expensive operation on some /// platforms, so this should be used with caution in performance-sensitive /// parts of code. - #[stable(feature = "backtrace", since = "1.50.0")] + #[stable(feature = "backtrace", since = "1.51.0")] #[inline(never)] // want to make sure there's a frame here to remove pub fn force_capture() -> Backtrace { Backtrace::create(Backtrace::force_capture as usize) @@ -346,7 +346,7 @@ impl Backtrace { /// Returns the status of this backtrace, indicating whether this backtrace /// request was unsupported, disabled, or a stack trace was actually /// captured. - #[stable(feature = "backtrace", since = "1.50.0")] + #[stable(feature = "backtrace", since = "1.51.0")] pub fn status(&self) -> BacktraceStatus { match self.inner { Inner::Unsupported => BacktraceStatus::Unsupported, @@ -356,7 +356,7 @@ impl Backtrace { } } -#[stable(feature = "backtrace", since = "1.50.0")] +#[stable(feature = "backtrace", since = "1.51.0")] impl fmt::Display for Backtrace { fn fmt(&self, fmt: &mut fmt::Formatter<'_>) -> fmt::Result { let mut capture = match &self.inner { diff --git a/library/std/src/error.rs b/library/std/src/error.rs index 5e3a9ba104e54..212e28cbca6a7 100644 --- a/library/std/src/error.rs +++ b/library/std/src/error.rs @@ -122,7 +122,7 @@ pub trait Error: Debug + Display { /// Note that not all errors contain a `Backtrace`. Also note that a /// `Backtrace` may actually be empty. For more information consult the /// `Backtrace` type itself. - #[stable(feature = "backtrace", since = "1.50.0")] + #[stable(feature = "backtrace", since = "1.51.0")] fn backtrace(&self) -> Option<&Backtrace> { None } From c66e9299081f798a516466fc36140868a30eb643 Mon Sep 17 00:00:00 2001 From: Ashley Mannix Date: Wed, 13 Jan 2021 15:18:16 +1000 Subject: [PATCH 3/5] add missing stability attribute to Backtrace::disabled --- library/std/src/backtrace.rs | 1 + 1 file changed, 1 insertion(+) diff --git a/library/std/src/backtrace.rs b/library/std/src/backtrace.rs index a8e7f8ae68be6..17b536ca55a24 100644 --- a/library/std/src/backtrace.rs +++ b/library/std/src/backtrace.rs @@ -303,6 +303,7 @@ impl Backtrace { /// Forcibly captures a disabled backtrace, regardless of environment /// variable configuration. + #[stable(feature = "backtrace", since = "1.51.0")] pub const fn disabled() -> Backtrace { Backtrace { inner: Inner::Disabled } } From 3624a7bc054a397b0cf5ec712fdccd3d55918bfa Mon Sep 17 00:00:00 2001 From: Ashley Mannix Date: Wed, 13 Jan 2021 17:09:44 +1000 Subject: [PATCH 4/5] add const stable attribute to Backtrace::disabled --- library/std/src/backtrace.rs | 1 + 1 file changed, 1 insertion(+) diff --git a/library/std/src/backtrace.rs b/library/std/src/backtrace.rs index 17b536ca55a24..2ee69fa53e1b1 100644 --- a/library/std/src/backtrace.rs +++ b/library/std/src/backtrace.rs @@ -304,6 +304,7 @@ impl Backtrace { /// Forcibly captures a disabled backtrace, regardless of environment /// variable configuration. #[stable(feature = "backtrace", since = "1.51.0")] + #[rustc_const_stable(feature = "const_backtrace_disabled", since = "1.51.0")] pub const fn disabled() -> Backtrace { Backtrace { inner: Inner::Disabled } } From 2307537fe5be8cffd93188d2ea3066902935e463 Mon Sep 17 00:00:00 2001 From: Ashley Mannix Date: Wed, 13 Jan 2021 19:38:18 +1000 Subject: [PATCH 5/5] remove stable backtrace feature attr --- compiler/rustc_errors/src/lib.rs | 1 - 1 file changed, 1 deletion(-) diff --git a/compiler/rustc_errors/src/lib.rs b/compiler/rustc_errors/src/lib.rs index 593e0d92031ff..be3140a6ea167 100644 --- a/compiler/rustc_errors/src/lib.rs +++ b/compiler/rustc_errors/src/lib.rs @@ -4,7 +4,6 @@ #![doc(html_root_url = "https://doc.rust-lang.org/nightly/nightly-rustc/")] #![feature(crate_visibility_modifier)] -#![feature(backtrace)] #![feature(nll)] #[macro_use]