use std::env;
fn needs_alloc_error_handler() -> Option<bool> {
use rustc_version::Channel;
let version = rustc_version::version_meta().ok()?;
if version.channel != Channel::Nightly {
return None;
}
let commit_date = version.commit_date?;
let year = commit_date.split('-').next()?.parse::<u32>().ok()?;
Some(year <= 2022)
}
fn main() {
println!("cargo:rustc-check-cfg=cfg(needs_alloc_error_handler)");
match env::var("CARGO_CFG_TARGET_OS") {
Ok(v) if v == "none" => (),
_ => return,
};
if let Some(true) = needs_alloc_error_handler() {
println!("cargo:rustc-cfg=needs_alloc_error_handler");
}
}