Skip to content

Commit

Permalink
Merge pull request #333 from dtolnay/stablebacktrace
Browse files Browse the repository at this point in the history
Turn on cfg(std_backtrace) on new enough stable rustc
  • Loading branch information
dtolnay committed Dec 26, 2023
2 parents 53109e6 + 26b0a26 commit 43f4af0
Showing 1 changed file with 8 additions and 0 deletions.
8 changes: 8 additions & 0 deletions build.rs
Original file line number Diff line number Diff line change
Expand Up @@ -46,13 +46,15 @@ const PROBE: &str = r#"
"#;

fn main() {
let mut error_generic_member_access = false;
if cfg!(feature = "std") {
println!("cargo:rerun-if-env-changed=RUSTC_BOOTSTRAP");

match compile_probe() {
Some(status) if status.success() => {
println!("cargo:rustc-cfg=std_backtrace");
println!("cargo:rustc-cfg=error_generic_member_access");
error_generic_member_access = true;
}
_ => {}
}
Expand All @@ -78,6 +80,12 @@ fn main() {
// https://github.com/rust-lang/rust/issues/71668
println!("cargo:rustc-cfg=anyhow_no_unsafe_op_in_unsafe_fn_lint");
}

if !error_generic_member_access && cfg!(feature = "std") && rustc >= 65 {
// std::backtrace::Backtrace
// https://blog.rust-lang.org/2022/11/03/Rust-1.65.0.html#stabilized-apis
println!("cargo:rustc-cfg=std_backtrace");
}
}

fn compile_probe() -> Option<ExitStatus> {
Expand Down

0 comments on commit 43f4af0

Please sign in to comment.