diff --git a/src/backtrace/libunwind.rs b/src/backtrace/libunwind.rs index 0cf6365f..fb2440bf 100644 --- a/src/backtrace/libunwind.rs +++ b/src/backtrace/libunwind.rs @@ -15,9 +15,20 @@ //! //! This is the default unwinding API for all non-Windows platforms currently. -use super::super::Bomb; use core::ffi::c_void; +struct Bomb { + enabled: bool, +} + +impl Drop for Bomb { + fn drop(&mut self) { + if self.enabled { + panic!("cannot panic during the backtrace function"); + } + } +} + pub enum Frame { Raw(*mut uw::_Unwind_Context), Cloned { diff --git a/src/capture.rs b/src/capture.rs index e0dd9c47..45bfc814 100644 --- a/src/capture.rs +++ b/src/capture.rs @@ -54,7 +54,7 @@ pub struct BacktraceFrame { #[derive(Clone)] enum Frame { Raw(crate::Frame), - #[allow(dead_code)] + #[cfg_attr(not(feature = "serialize-rustc"), allow(dead_code))] Deserialized { ip: usize, symbol_address: usize, diff --git a/src/lib.rs b/src/lib.rs index 44a0bc64..60f6c0a9 100644 --- a/src/lib.rs +++ b/src/lib.rs @@ -96,7 +96,6 @@ // When we're building as part of libstd, silence all warnings since they're // irrelevant as this crate is developed out-of-tree. #![cfg_attr(backtrace_in_libstd, allow(warnings))] -#![cfg_attr(not(feature = "std"), allow(dead_code))] // We know this is deprecated, it's only here for back-compat reasons. #![cfg_attr(feature = "rustc-serialize", allow(deprecated))] @@ -140,21 +139,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; diff --git a/src/symbolize/gimli.rs b/src/symbolize/gimli.rs index 3b28bf74..eb5c183b 100644 --- a/src/symbolize/gimli.rs +++ b/src/symbolize/gimli.rs @@ -64,7 +64,6 @@ struct Mapping { } enum Either { - #[allow(dead_code)] A(A), B(B), } @@ -319,6 +318,7 @@ fn create_mapping(lib: &Library) -> Option { } // unsafe because this is required to be externally synchronized +#[cfg(feature = "std")] pub unsafe fn clear_symbol_cache() { Cache::with_global(|cache| cache.mappings.clear()); } @@ -522,6 +522,7 @@ impl Symbol<'_> { } } + #[cfg(feature = "std")] pub fn filename(&self) -> Option<&Path> { match self { Symbol::Frame { location, .. } => { diff --git a/src/symbolize/mod.rs b/src/symbolize/mod.rs index a7c19950..7e4668b1 100644 --- a/src/symbolize/mod.rs +++ b/src/symbolize/mod.rs @@ -111,7 +111,6 @@ pub enum ResolveWhat<'a> { } impl<'a> ResolveWhat<'a> { - #[allow(dead_code)] fn address_or_ip(&self) -> *mut c_void { match self { ResolveWhat::Address(a) => adjust_ip(*a), @@ -313,11 +312,10 @@ cfg_if::cfg_if! { /// A wrapper around a symbol name to provide ergonomic accessors to the /// demangled name, the raw bytes, the raw string, etc. -// Allow dead code for when the `cpp_demangle` feature is not enabled. -#[allow(dead_code)] pub struct SymbolName<'a> { bytes: &'a [u8], demangled: Option>, + #[cfg_attr(not(feature = "cpp_demangle"), allow(dead_code))] cpp_demangled: OptionCppSymbol<'a>, }