@@ -5,28 +5,13 @@ use std::path::{Path, PathBuf};
5
5
6
6
use { trace, resolve, SymbolName } ;
7
7
8
- // Ok so the `//~ HACK` directives here are, well, hacks. Right now we want to
9
- // compile on stable for serde support, but we also want to use
10
- // #[derive(Serialize, Deserialize)] macros *along* with the
11
- // `#[derive(RustcEncodable, RustcDecodable)]` macros. In theory both of these
12
- // can be behind a #[cfg_attr], but that unfortunately doesn't work for two
13
- // reasons:
14
- //
15
- // 1. rust-lang/rust#32957 - means the include! of this module doesn't expand
16
- // the RustcDecodable/RustcEncodable blocks.
17
- // 2. serde-rs/serde#148 - means that Serialize/Deserialize won't get expanded.
18
- //
19
- // We just hack around it by doing #[cfg_attr] manually essentially. Our build
20
- // script will just strip the `//~ HACKn` prefixes here if the corresponding
21
- // feature is enabled.
22
-
23
8
/// Representation of an owned and self-contained backtrace.
24
9
///
25
10
/// This structure can be used to capture a backtrace at various points in a
26
11
/// program and later used to inspect what the backtrace was at that time.
27
12
#[ derive( Clone ) ]
28
- //~ HACK1 #[ derive(RustcDecodable, RustcEncodable)]
29
- //~ HACK2 #[ derive(Deserialize, Serialize)]
13
+ # [ cfg_attr ( feature = "serialize-rustc" , derive( RustcDecodable , RustcEncodable ) ) ]
14
+ # [ cfg_attr ( feature = "serialize-serde" , derive( Deserialize , Serialize ) ) ]
30
15
pub struct Backtrace {
31
16
frames : Vec < BacktraceFrame > ,
32
17
}
@@ -36,8 +21,8 @@ pub struct Backtrace {
36
21
/// This type is returned as a list from `Backtrace::frames` and represents one
37
22
/// stack frame in a captured backtrace.
38
23
#[ derive( Clone ) ]
39
- //~ HACK1 #[ derive(RustcDecodable, RustcEncodable)]
40
- //~ HACK2 #[ derive(Deserialize, Serialize)]
24
+ # [ cfg_attr ( feature = "serialize-rustc" , derive( RustcDecodable , RustcEncodable ) ) ]
25
+ # [ cfg_attr ( feature = "serialize-serde" , derive( Deserialize , Serialize ) ) ]
41
26
pub struct BacktraceFrame {
42
27
ip : usize ,
43
28
symbol_address : usize ,
@@ -49,8 +34,8 @@ pub struct BacktraceFrame {
49
34
/// This type is returned as a list from `BacktraceFrame::symbols` and
50
35
/// represents the metadata for a symbol in a backtrace.
51
36
#[ derive( Clone ) ]
52
- //~ HACK1 #[ derive(RustcDecodable, RustcEncodable)]
53
- //~ HACK2 #[ derive(Deserialize, Serialize)]
37
+ # [ cfg_attr ( feature = "serialize-rustc" , derive( RustcDecodable , RustcEncodable ) ) ]
38
+ # [ cfg_attr ( feature = "serialize-serde" , derive( Deserialize , Serialize ) ) ]
54
39
pub struct BacktraceSymbol {
55
40
name : Option < Vec < u8 > > ,
56
41
addr : Option < usize > ,
0 commit comments