Skip to content

Maintain compatibility with Rust 1.25 #137

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Merged
merged 6 commits into from
Dec 13, 2018
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
4 changes: 4 additions & 0 deletions .travis.yml
Original file line number Diff line number Diff line change
Expand Up @@ -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:
Expand Down
3 changes: 3 additions & 0 deletions Cargo.toml
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand Down
13 changes: 13 additions & 0 deletions build.rs
Original file line number Diff line number Diff line change
@@ -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.
//
// <https://github.com/rust-lang/rust/pull/53910>
ac.emit_rustc_version(1, 30);

println!("cargo:rerun-if-changed=build.rs");
}
11 changes: 10 additions & 1 deletion src/symbolize/dbghelp.rs
Original file line number Diff line number Diff line change
Expand Up @@ -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::*;
Expand Down
8 changes: 5 additions & 3 deletions src/types.rs
Original file line number Diff line number Diff line change
Expand Up @@ -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`.");
}
}

Expand All @@ -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)),
}
}

Expand Down