diff --git a/Cargo.lock b/Cargo.lock index 9c359b464ef1d..8b2da4d448ce6 100644 --- a/Cargo.lock +++ b/Cargo.lock @@ -3086,6 +3086,7 @@ dependencies = [ "fmt_macros", "graphviz", "jobserver", + "lazy_static 1.4.0", "log", "measureme", "parking_lot", diff --git a/src/librustc/Cargo.toml b/src/librustc/Cargo.toml index b65635be54a3f..7dfc5d55056ab 100644 --- a/src/librustc/Cargo.toml +++ b/src/librustc/Cargo.toml @@ -16,6 +16,7 @@ fmt_macros = { path = "../libfmt_macros" } graphviz = { path = "../libgraphviz" } jobserver = "0.1" scoped-tls = "1.0" +lazy_static = "1.3" log = { version = "0.4", features = ["release_max_level_info", "std"] } rustc-rayon = "0.3.0" rustc-rayon-core = "0.3.0" diff --git a/src/librustc/mir/interpret/error.rs b/src/librustc/mir/interpret/error.rs index 349dbd74ad1c9..5199aca311990 100644 --- a/src/librustc/mir/interpret/error.rs +++ b/src/librustc/mir/interpret/error.rs @@ -223,7 +223,11 @@ impl From for InterpErrorInfo<'tcx> { impl<'tcx> From> for InterpErrorInfo<'tcx> { fn from(kind: InterpError<'tcx>) -> Self { - let backtrace = match env::var("RUSTC_CTFE_BACKTRACE") { + lazy_static::lazy_static! { + static ref ENV_VAR: Result = env::var("RUSTC_CTFE_BACKTRACE"); + } + + let backtrace = match *ENV_VAR { // Matching `RUST_BACKTRACE` -- we treat "0" the same as "not present". Ok(ref val) if val != "0" => { let mut backtrace = Backtrace::new_unresolved();