ZDN7BJ3JA3VL4AYWX3SV24GHP6NCAETJVAKAXKMIZTLHTWLUNMOQC
EXRAFG37562NH775A4LDPP5FNKXLPLIZSJ3FCOBINUDKRFBJHCXAC
CI66AAY6BN4S65RNWUAZWSVGRUDZ6C3P2KVGXETUS342L5KGPRHQC
RERVQKZGW2CFKAPUKQPQAN6XSLFWFRKDOTJGBWZI2JIWGHQRWZAQC
CITEDKPB6MKVZUEYEDE5ZKTNVY35HCOAXKDPYG7YLLEOVFNMSRXQC
3LI5FAF5ULXOWBMTG4XCUOMUPVROSFDY6FWGE574OH4JGPMOPNVAC
UM7DFUYLW4HSMBUDZY3R6ZNJRSX2E75C4DYV3MJAU57EUCGE6JLAC
GZZOJ7ZUSBPI3HXIV5UCFNMCDAMZPPLISY2UDV73FDN74HZ3AWJAC
G6C7MPYR535SR3WLKSOE3FCAX7LT7D7766RVRC76UW77LZBWRF5AC
use std::env;
use std::process::Command;
use std::str;
fn main() {
let compiler = match rustc_version() {
Some(compiler) => compiler,
None => return,
};
if compiler.nightly {
println!("cargo:rustc-cfg=backtrace");
}
}
struct Compiler {
nightly: bool,
}
fn rustc_version() -> Option<Compiler> {
let rustc = match env::var_os("RUSTC") {
Some(rustc) => rustc,
None => return None,
};
let output = match Command::new(rustc).arg("--version").output() {
Ok(output) => output,
Err(_) => return None,
};
let version = match str::from_utf8(&output.stdout) {
Ok(version) => version,
Err(_) => return None,
};
Some(Compiler {
nightly: version.contains("nightly") || version.contains("dev"),
})
}
let backtrace = self.backtrace();
match backtrace.status() {
BacktraceStatus::Captured => {
writeln!(f, "\n{}", backtrace)?;
}
BacktraceStatus::Disabled => {
writeln!(
f,
"\nbacktrace disabled; run with RUST_LIB_BACKTRACE=1 environment variable to display a backtrace"
)?;
#[cfg(backtrace)]
{
let backtrace = self.backtrace();
match backtrace.status() {
BacktraceStatus::Captured => {
writeln!(f, "\n{}", backtrace)?;
}
BacktraceStatus::Disabled => {
writeln!(
f,
"\nbacktrace disabled; run with RUST_LIB_BACKTRACE=1 environment variable to display a backtrace"
)?;
}
_ => {}