File tree 1 file changed +18
-20
lines changed
1 file changed +18
-20
lines changed Original file line number Diff line number Diff line change @@ -498,26 +498,24 @@ pub fn get_backtrace_style() -> Option<BacktraceStyle> {
498
498
// to optimize away callers.
499
499
return None ;
500
500
}
501
- BacktraceStyle :: from_u8 ( SHOULD_CAPTURE . load ( Ordering :: Acquire ) ) . map ( Some ) . unwrap_or_else ( || {
502
- let env_var = crate :: env:: var_os ( "RUST_BACKTRACE" ) ;
503
- let style = env_var
504
- . and_then ( |var| {
505
- var. to_str ( ) . map ( |s| match s {
506
- "0" => BacktraceStyle :: Off ,
507
- "full" => BacktraceStyle :: Full ,
508
- _ => BacktraceStyle :: Short ,
509
- } )
510
- } )
511
- . unwrap_or_else ( || {
512
- if crate :: sys:: FULL_BACKTRACE_DEFAULT {
513
- BacktraceStyle :: Full
514
- } else {
515
- BacktraceStyle :: Short
516
- }
517
- } ) ;
518
- set_backtrace_style ( style) ;
519
- Some ( style)
520
- } )
501
+ if let Some ( style) = BacktraceStyle :: from_u8 ( SHOULD_CAPTURE . load ( Ordering :: Acquire ) ) {
502
+ return Some ( style) ;
503
+ }
504
+
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 => {
510
+ if crate :: sys:: FULL_BACKTRACE_DEFAULT {
511
+ BacktraceStyle :: Full
512
+ } else {
513
+ BacktraceStyle :: Short
514
+ }
515
+ }
516
+ } ;
517
+ set_backtrace_style ( format) ;
518
+ Some ( format)
521
519
}
522
520
523
521
#[ cfg( test) ]
You can’t perform that action at this time.
0 commit comments