Skip to content

Commit 37a0753

Browse files
committed
Use autocfg crate to detect Rust features.
Issue #135
1 parent 06f00c4 commit 37a0753

File tree

4 files changed

+19
-6
lines changed

4 files changed

+19
-6
lines changed

Cargo.toml

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -32,6 +32,9 @@ gimli = { version = "0.16.0", optional = true }
3232
memmap = { version = "0.7.0", optional = true }
3333
object = { version = "0.9.0", optional = true }
3434

35+
[build-dependencies]
36+
autocfg = "0.1"
37+
3538
[target.'cfg(unix)'.dependencies]
3639
libc = { version = "0.2", default-features = false }
3740

build.rs

Lines changed: 10 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,10 @@
1+
extern crate autocfg;
2+
3+
fn main() {
4+
let ac = autocfg::new();
5+
6+
// `repr_align` was stabilized in Rust 1.25:
7+
//
8+
// https://github.com/rust-lang/rust/blob/master/RELEASES.md#version-1250-2018-03-29
9+
ac.emit_rustc_version(1, 25);
10+
}

src/backtrace/dbghelp.rs

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -37,7 +37,7 @@ impl Frame {
3737

3838
// This beast is to maintain Rust 1.18 Compatibility
3939
cfg_if! {
40-
if #[cfg(feature = "repr_align")] {
40+
if #[cfg(rustc_1_25)] {
4141
#[repr(C, align(16))] // required by `CONTEXT`, is a FIXME in winapi right now
4242
struct MyContext(CONTEXT);
4343

@@ -122,7 +122,7 @@ cfg_if! {
122122
}
123123
}
124124
} else {
125-
compile_error!("`no_std` is not supported for versions of Rust prior to 1.24.");
125+
compile_error!("`no_std` is not supported for versions of Rust prior to 1.25.");
126126
}
127127
}
128128

src/symbolize/dbghelp.rs

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -68,18 +68,18 @@ impl Symbol {
6868
}
6969

7070
// Maintain Rust 1.18 Compatibility
71-
#[cfg(feature = "repr_align")]
71+
#[cfg(rustc_1_25)]
7272
#[repr(C, align(8))]
7373
struct Aligned8<T>(T);
7474

7575
pub unsafe fn resolve(addr: *mut c_void, cb: &mut FnMut(&super::Symbol)) {
7676
let size: usize = 2 * MAX_SYM_NAME + mem::size_of::<SYMBOL_INFOW>();
77-
#[cfg(feature = "repr_align")]
77+
#[cfg(rustc_1_25)]
7878
let mut data = Aligned8([0u8; size]);
79-
#[cfg(not(feature = "repr_align"))]
79+
#[cfg(not(rustc_1_25))]
8080
let mut data = vec![0u8; size];
8181

82-
#[cfg(feature = "repr_align")]
82+
#[cfg(rustc_1_25)]
8383
let data = &mut data.0;
8484

8585
let info = &mut *(data.as_mut_ptr() as *mut SYMBOL_INFOW);

0 commit comments

Comments
 (0)