Skip to content

Commit

Permalink
Merge of #619: remove some instances of dead_code
Browse files Browse the repository at this point in the history
  • Loading branch information
workingjubilee committed May 6, 2024
2 parents 4cbe6b6 + f996e66 commit f63b581
Show file tree
Hide file tree
Showing 3 changed files with 20 additions and 18 deletions.
13 changes: 12 additions & 1 deletion src/backtrace/libunwind.rs
Expand Up @@ -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;

Expand Down Expand Up @@ -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());
Expand Down
10 changes: 8 additions & 2 deletions 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};
Expand Down Expand Up @@ -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,
Expand All @@ -62,20 +64,23 @@ 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,
}
}

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,
}
}

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,
..
Expand All @@ -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);
}
Expand Down
15 changes: 0 additions & 15 deletions src/lib.rs
Expand Up @@ -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;
Expand Down

0 comments on commit f63b581

Please sign in to comment.