diff --git a/.travis.yml b/.travis.yml index 7e0080261..22e77326c 100644 --- a/.travis.yml +++ b/.travis.yml @@ -43,6 +43,10 @@ matrix: - rust: nightly script: *test_all + # Make sure the default crate builds with 1.25.0 + - rust: 1.25.0 + script: cargo test + # Upload docs on nightly - rust: nightly script: diff --git a/Cargo.toml b/Cargo.toml index 2f5a9907b..b0c3427d8 100644 --- a/Cargo.toml +++ b/Cargo.toml @@ -41,6 +41,9 @@ winapi = { version = "0.3.3", features = ["dbghelp", "processthreadsapi", "winnt [target.'cfg(all(unix, not(target_os = "fuchsia"), not(target_os = "emscripten"), not(target_os = "macos"), not(target_os = "ios")))'.dependencies] backtrace-sys = { path = "backtrace-sys", version = "0.1.17", optional = true } +[build-dependencies] +autocfg = "0.1" + # Each feature controls the two phases of finding a backtrace: getting a # backtrace and then resolving instruction pointers to symbols. The default # feature enables all the necessary features for each platform this library diff --git a/build.rs b/build.rs new file mode 100644 index 000000000..a648ea1ce --- /dev/null +++ b/build.rs @@ -0,0 +1,13 @@ +extern crate autocfg; + +fn main() { + let ac = autocfg::new(); + + // ffi types moved from `std` to `core` in Rust 1.30, so we need to adjust imports based on + // this. + // + // + ac.emit_rustc_version(1, 30); + + println!("cargo:rerun-if-changed=build.rs"); +} diff --git a/src/symbolize/dbghelp.rs b/src/symbolize/dbghelp.rs index e6324bbb7..abc89868a 100644 --- a/src/symbolize/dbghelp.rs +++ b/src/symbolize/dbghelp.rs @@ -10,9 +10,18 @@ #![allow(bad_style)] +// This is a hack for compatibility with rustc 1.25.0. The no_std mode of this +// crate is not supported pre-1.30.0, but in std mode the `char` module here +// moved in rustc 1.26.0 (ish). As a result, in std mode we use `std::char` to +// retain compatibility with rustc 1.25.0, but in `no_std` mode (which is +// 1.30.0+ already) we use `core::char`. +#[cfg(feature = "std")] +use std::char; +#[cfg(not(feature = "std"))] +use core::char; + use core::mem; use core::slice; -use core::char; use winapi::ctypes::*; use winapi::shared::basetsd::*; diff --git a/src/types.rs b/src/types.rs index eefcf426e..236931466 100644 --- a/src/types.rs +++ b/src/types.rs @@ -7,8 +7,10 @@ cfg_if! { use std::fmt; use std::path::PathBuf; use std::prelude::v1::*; - } else { + } else if #[cfg(rustc_1_30)] { pub use core::ffi::c_void; + } else { + compile_error!("`backtrace` requires Rust >=1.30.0 to support `no_std`."); } } @@ -31,8 +33,8 @@ impl<'a> BytesOrWideString<'a> { use self::BytesOrWideString::*; match self { - Bytes(slice) => String::from_utf8_lossy(slice), - Wide(wide) => Cow::Owned(String::from_utf16_lossy(wide)), + &Bytes(slice) => String::from_utf8_lossy(slice), + &Wide(wide) => Cow::Owned(String::from_utf16_lossy(wide)), } }