Merge pull request #258 from Fishrock123/error-backtrace-stable-display

error: allow backtrace Option to be Display on stable
This commit is contained in:
Yoshua Wuyts 2020-11-27 14:46:01 +01:00 committed by GitHub
commit 4599842ca7
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
1 changed files with 12 additions and 1 deletions

View File

@ -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.
///
@ -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
}