Skip to content

Commit 7654d4b

Browse files
committed
compiler: always use var_os("RUST_BACKTRACE")
There are 3 instances of var(...) and 3 instances of var_os(...); the latter avoids an appearance of unhandled error, so use it everywhere.
1 parent d4ba2b4 commit 7654d4b

File tree

2 files changed

+3
-3
lines changed
  • compiler
    • rustc_codegen_cranelift/build_system
    • rustc_driver_impl/src

2 files changed

+3
-3
lines changed

compiler/rustc_codegen_cranelift/build_system/main.rs

+1-1
Original file line numberDiff line numberDiff line change
@@ -55,7 +55,7 @@ enum CodegenBackend {
5555
}
5656

5757
fn main() {
58-
if env::var("RUST_BACKTRACE").is_err() {
58+
if env::var_os("RUST_BACKTRACE").is_none() {
5959
env::set_var("RUST_BACKTRACE", "1");
6060
}
6161
env::set_var("CG_CLIF_DISABLE_INCR_CACHE", "1");

compiler/rustc_driver_impl/src/lib.rs

+2-2
Original file line numberDiff line numberDiff line change
@@ -1287,7 +1287,7 @@ pub fn ice_path() -> &'static Option<PathBuf> {
12871287
if !rustc_feature::UnstableFeatures::from_environment(None).is_nightly_build() {
12881288
return None;
12891289
}
1290-
if let Ok("0") = std::env::var("RUST_BACKTRACE").as_deref() {
1290+
if let Some(s) = std::env::var_os("RUST_BACKTRACE") && s == "0" {
12911291
return None;
12921292
}
12931293
let mut path = match std::env::var("RUSTC_ICE").as_deref() {
@@ -1322,7 +1322,7 @@ pub fn install_ice_hook(bug_report_url: &'static str, extra_info: fn(&Handler))
13221322
// by the user. Compiler developers and other rustc users can
13231323
// opt in to less-verbose backtraces by manually setting "RUST_BACKTRACE"
13241324
// (e.g. `RUST_BACKTRACE=1`)
1325-
if std::env::var("RUST_BACKTRACE").is_err() {
1325+
if std::env::var_os("RUST_BACKTRACE").is_none() {
13261326
std::env::set_var("RUST_BACKTRACE", "full");
13271327
}
13281328

0 commit comments

Comments
 (0)