Skip to content

Commit 4599842

Browse files
authored
Merge pull request #258 from Fishrock123/error-backtrace-stable-display
error: allow backtrace Option to be Display on stable
2 parents c595742 + 10c3f60 commit 4599842

File tree

1 file changed

+12
-1
lines changed

1 file changed

+12
-1
lines changed

src/error.rs

Lines changed: 12 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -19,6 +19,17 @@ pub struct Error {
1919
type_name: Option<&'static str>,
2020
}
2121

22+
#[allow(unreachable_pub)]
23+
#[derive(Debug)]
24+
#[doc(hidden)]
25+
pub struct BacktracePlaceholder;
26+
27+
impl Display for BacktracePlaceholder {
28+
fn fmt(&self, _: &mut fmt::Formatter<'_>) -> fmt::Result {
29+
unreachable!()
30+
}
31+
}
32+
2233
impl Error {
2334
/// Create a new error object from any error type.
2435
///
@@ -108,7 +119,7 @@ impl Error {
108119

109120
#[cfg(not(backtrace))]
110121
#[allow(missing_docs)]
111-
pub fn backtrace(&self) -> Option<()> {
122+
pub const fn backtrace(&self) -> Option<BacktracePlaceholder> {
112123
None
113124
}
114125

0 commit comments

Comments
 (0)