diff --git a/src/backtrace/libunwind.rs b/src/backtrace/libunwind.rs index c3d88605..d439be06 100644 --- a/src/backtrace/libunwind.rs +++ b/src/backtrace/libunwind.rs @@ -15,7 +15,6 @@ //! //! This is the default unwinding API for all non-Windows platforms currently. -use super::super::Bomb; use core::ffi::c_void; use core::ptr::addr_of_mut; @@ -100,6 +99,18 @@ impl Clone for Frame { } } +struct Bomb { + enabled: bool, +} + +impl Drop for Bomb { + fn drop(&mut self) { + if self.enabled { + panic!("cannot panic during the backtrace function"); + } + } +} + #[inline(always)] pub unsafe fn trace(mut cb: &mut dyn FnMut(&super::Frame) -> bool) { uw::_Unwind_Backtrace(trace_fn, addr_of_mut!(cb).cast()); diff --git a/src/capture.rs b/src/capture.rs index d1691b89..f7d4b4fe 100644 --- a/src/capture.rs +++ b/src/capture.rs @@ -1,5 +1,7 @@ +#[cfg(feature = "serde")] +use crate::resolve; use crate::PrintFmt; -use crate::{resolve, resolve_frame, trace, BacktraceFmt, Symbol, SymbolName}; +use crate::{resolve_frame, trace, BacktraceFmt, Symbol, SymbolName}; use std::ffi::c_void; use std::fmt; use std::path::{Path, PathBuf}; @@ -50,7 +52,7 @@ pub struct BacktraceFrame { #[derive(Clone)] enum Frame { Raw(crate::Frame), - #[allow(dead_code)] + #[cfg(feature = "serde")] Deserialized { ip: usize, symbol_address: usize, @@ -62,6 +64,7 @@ impl Frame { fn ip(&self) -> *mut c_void { match *self { Frame::Raw(ref f) => f.ip(), + #[cfg(feature = "serde")] Frame::Deserialized { ip, .. } => ip as *mut c_void, } } @@ -69,6 +72,7 @@ impl Frame { fn symbol_address(&self) -> *mut c_void { match *self { Frame::Raw(ref f) => f.symbol_address(), + #[cfg(feature = "serde")] Frame::Deserialized { symbol_address, .. } => symbol_address as *mut c_void, } } @@ -76,6 +80,7 @@ impl Frame { fn module_base_address(&self) -> Option<*mut c_void> { match *self { Frame::Raw(ref f) => f.module_base_address(), + #[cfg(feature = "serde")] Frame::Deserialized { module_base_address, .. @@ -97,6 +102,7 @@ impl Frame { }; match *self { Frame::Raw(ref f) => resolve_frame(f, sym), + #[cfg(feature = "serde")] Frame::Deserialized { ip, .. } => { resolve(ip as *mut c_void, sym); } diff --git a/src/lib.rs b/src/lib.rs index 7b4bbc2e..e9be4009 100644 --- a/src/lib.rs +++ b/src/lib.rs @@ -138,21 +138,6 @@ cfg_if::cfg_if! { } } -#[allow(dead_code)] -struct Bomb { - enabled: bool, -} - -#[allow(dead_code)] -impl Drop for Bomb { - fn drop(&mut self) { - if self.enabled { - panic!("cannot panic during the backtrace function"); - } - } -} - -#[allow(dead_code)] #[cfg(feature = "std")] mod lock { use std::boxed::Box;