Skip to content

Commit f63b581

Browse files
Merge of #619: remove some instances of dead_code
2 parents 4cbe6b6 + f996e66 commit f63b581

File tree

3 files changed

+20
-18
lines changed

3 files changed

+20
-18
lines changed

src/backtrace/libunwind.rs

+12-1
Original file line numberDiff line numberDiff line change
@@ -15,7 +15,6 @@
1515
//!
1616
//! This is the default unwinding API for all non-Windows platforms currently.
1717
18-
use super::super::Bomb;
1918
use core::ffi::c_void;
2019
use core::ptr::addr_of_mut;
2120

@@ -100,6 +99,18 @@ impl Clone for Frame {
10099
}
101100
}
102101

102+
struct Bomb {
103+
enabled: bool,
104+
}
105+
106+
impl Drop for Bomb {
107+
fn drop(&mut self) {
108+
if self.enabled {
109+
panic!("cannot panic during the backtrace function");
110+
}
111+
}
112+
}
113+
103114
#[inline(always)]
104115
pub unsafe fn trace(mut cb: &mut dyn FnMut(&super::Frame) -> bool) {
105116
uw::_Unwind_Backtrace(trace_fn, addr_of_mut!(cb).cast());

src/capture.rs

+8-2
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,7 @@
1+
#[cfg(feature = "serde")]
2+
use crate::resolve;
13
use crate::PrintFmt;
2-
use crate::{resolve, resolve_frame, trace, BacktraceFmt, Symbol, SymbolName};
4+
use crate::{resolve_frame, trace, BacktraceFmt, Symbol, SymbolName};
35
use std::ffi::c_void;
46
use std::fmt;
57
use std::path::{Path, PathBuf};
@@ -50,7 +52,7 @@ pub struct BacktraceFrame {
5052
#[derive(Clone)]
5153
enum Frame {
5254
Raw(crate::Frame),
53-
#[allow(dead_code)]
55+
#[cfg(feature = "serde")]
5456
Deserialized {
5557
ip: usize,
5658
symbol_address: usize,
@@ -62,20 +64,23 @@ impl Frame {
6264
fn ip(&self) -> *mut c_void {
6365
match *self {
6466
Frame::Raw(ref f) => f.ip(),
67+
#[cfg(feature = "serde")]
6568
Frame::Deserialized { ip, .. } => ip as *mut c_void,
6669
}
6770
}
6871

6972
fn symbol_address(&self) -> *mut c_void {
7073
match *self {
7174
Frame::Raw(ref f) => f.symbol_address(),
75+
#[cfg(feature = "serde")]
7276
Frame::Deserialized { symbol_address, .. } => symbol_address as *mut c_void,
7377
}
7478
}
7579

7680
fn module_base_address(&self) -> Option<*mut c_void> {
7781
match *self {
7882
Frame::Raw(ref f) => f.module_base_address(),
83+
#[cfg(feature = "serde")]
7984
Frame::Deserialized {
8085
module_base_address,
8186
..
@@ -97,6 +102,7 @@ impl Frame {
97102
};
98103
match *self {
99104
Frame::Raw(ref f) => resolve_frame(f, sym),
105+
#[cfg(feature = "serde")]
100106
Frame::Deserialized { ip, .. } => {
101107
resolve(ip as *mut c_void, sym);
102108
}

src/lib.rs

-15
Original file line numberDiff line numberDiff line change
@@ -138,21 +138,6 @@ cfg_if::cfg_if! {
138138
}
139139
}
140140

141-
#[allow(dead_code)]
142-
struct Bomb {
143-
enabled: bool,
144-
}
145-
146-
#[allow(dead_code)]
147-
impl Drop for Bomb {
148-
fn drop(&mut self) {
149-
if self.enabled {
150-
panic!("cannot panic during the backtrace function");
151-
}
152-
}
153-
}
154-
155-
#[allow(dead_code)]
156141
#[cfg(feature = "std")]
157142
mod lock {
158143
use std::boxed::Box;

0 commit comments

Comments
 (0)