@@ -463,11 +463,10 @@ static SHOULD_CAPTURE: AtomicU8 = AtomicU8::new(0);
|
463 | 463 | /// environment variable; see the details in [`get_backtrace_style`]. |
464 | 464 | #[unstable(feature = "panic_backtrace_config", issue = "93346")] |
465 | 465 | pub fn set_backtrace_style(style: BacktraceStyle) { |
466 | | -if !cfg!(feature = "backtrace") { |
467 | | -// If the `backtrace` feature of this crate isn't enabled, skip setting. |
468 | | -return; |
| 466 | +if cfg!(feature = "backtrace") { |
| 467 | +// If the `backtrace` feature of this crate is enabled, set the backtrace style. |
| 468 | +SHOULD_CAPTURE.store(style.as_u8(), Ordering::Release); |
469 | 469 | } |
470 | | -SHOULD_CAPTURE.store(style.as_u8(), Ordering::Release); |
471 | 470 | } |
472 | 471 | |
473 | 472 | /// Checks whether the standard library's panic hook will capture and print a |
@@ -503,21 +502,13 @@ pub fn get_backtrace_style() -> Option<BacktraceStyle> {
|
503 | 502 | return Some(style); |
504 | 503 | } |
505 | 504 | |
506 | | -let format = crate::env::var_os("RUST_BACKTRACE") |
507 | | -.map(|x| { |
508 | | -if &x == "0" { |
509 | | -BacktraceStyle::Off |
510 | | -} else if &x == "full" { |
511 | | -BacktraceStyle::Full |
512 | | -} else { |
513 | | -BacktraceStyle::Short |
514 | | -} |
515 | | -}) |
516 | | -.unwrap_or(if crate::sys::FULL_BACKTRACE_DEFAULT { |
517 | | -BacktraceStyle::Full |
518 | | -} else { |
519 | | -BacktraceStyle::Off |
520 | | -}); |
| 505 | +let format = match crate::env::var_os("RUST_BACKTRACE") { |
| 506 | +Some(x) if &x == "0" => BacktraceStyle::Off, |
| 507 | +Some(x) if &x == "full" => BacktraceStyle::Full, |
| 508 | +Some(_) => BacktraceStyle::Short, |
| 509 | +None if crate::sys::FULL_BACKTRACE_DEFAULT => BacktraceStyle::Full, |
| 510 | +None => BacktraceStyle::Off, |
| 511 | +}; |
521 | 512 | set_backtrace_style(format); |
522 | 513 | Some(format) |
523 | 514 | } |
|