Skip to content

Commit

Permalink
Merge pull request #258 from Fishrock123/error-backtrace-stable-display
Browse files Browse the repository at this point in the history
error: allow backtrace Option to be Display on stable
  • Loading branch information
yoshuawuyts authored Nov 27, 2020
2 parents c595742 + 10c3f60 commit 4599842
Showing 1 changed file with 12 additions and 1 deletion.
13 changes: 12 additions & 1 deletion src/error.rs
Original file line number Diff line number Diff line change
Expand Up @@ -19,6 +19,17 @@ pub struct Error {
type_name: Option<&'static str>,
}

#[allow(unreachable_pub)]
#[derive(Debug)]
#[doc(hidden)]
pub struct BacktracePlaceholder;

impl Display for BacktracePlaceholder {
fn fmt(&self, _: &mut fmt::Formatter<'_>) -> fmt::Result {
unreachable!()
}
}

impl Error {
/// Create a new error object from any error type.
///
Expand Down Expand Up @@ -108,7 +119,7 @@ impl Error {

#[cfg(not(backtrace))]
#[allow(missing_docs)]
pub fn backtrace(&self) -> Option<()> {
pub const fn backtrace(&self) -> Option<BacktracePlaceholder> {
None
}

Expand Down

0 comments on commit 4599842

Please sign in to comment.