Skip to content

Commit

Permalink
Turn on cfg(std_backtrace) on new enough stable rustc
Browse files Browse the repository at this point in the history
  • Loading branch information
dtolnay committed Dec 26, 2023
1 parent 53109e6 commit 26b0a26
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 26b0a26

Please sign in to comment.