diff options
| author | Jane Lusby <jlusby@yaah.dev> | 2020-02-10 13:15:03 -0800 |
|---|---|---|
| committer | Jane Lusby <jlusby@yaah.dev> | 2020-02-10 14:28:32 -0800 |
| commit | 49204563e13f57917cc22ac8f8b608927a432038 (patch) | |
| tree | 0292c054fdff24e1e5235578a5b96bf7dcb6d1fa /src/libstd | |
| parent | b637c0e84a9dbb5883130e0ea1e5ee9e8acf3bc1 (diff) | |
| download | rust-49204563e13f57917cc22ac8f8b608927a432038.tar.gz rust-49204563e13f57917cc22ac8f8b608927a432038.zip | |
Get vaguely working with a test for checking output
Diffstat (limited to 'src/libstd')
| -rw-r--r-- | src/libstd/backtrace.rs | 27 |
1 files changed, 26 insertions, 1 deletions
diff --git a/src/libstd/backtrace.rs b/src/libstd/backtrace.rs index 6b4ae77cec7..f6c34486d70 100644 --- a/src/libstd/backtrace.rs +++ b/src/libstd/backtrace.rs @@ -152,7 +152,6 @@ struct BacktraceFrame { symbols: Vec<BacktraceSymbol>, } -#[derive(Debug)] struct BacktraceSymbol { name: Option<Vec<u8>>, filename: Option<BytesOrWide>, @@ -164,6 +163,16 @@ enum BytesOrWide { Wide(Vec<u16>), } +impl fmt::Debug for BacktraceSymbol { + fn fmt(&self, fmt: &mut fmt::Formatter<'_>) -> fmt::Result { + fmt.debug_struct("BacktraceSymbol") + .field("name", &self.name.as_ref().map(|b| backtrace::SymbolName::new(b))) + .field("filename", &self.filename) + .field("lineno", &self.lineno) + .finish() + } +} + impl fmt::Debug for BytesOrWide { fn fmt(&self, fmt: &mut fmt::Formatter<'_>) -> fmt::Result { output_filename( @@ -364,3 +373,19 @@ impl Capture { } } } + +#[cfg(test)] +mod tests { + use super::*; + + #[test] + fn debug_backtrace_fmt() { + let bt = Backtrace::capture(); + eprintln!("uncaptured: {:?}", bt); + let bt = Backtrace::force_capture(); + eprintln!("captured: {:?}", bt); + eprintln!("display print: {}", bt); + eprintln!("resolved: {:?}", bt); + unimplemented!(); + } +} |
