Skip to content

Commit

Permalink
fix: rm extra indentation and use byte comparison
Browse files Browse the repository at this point in the history
  • Loading branch information
Konippi committed Aug 3, 2024
1 parent c77a68a commit 52a29a0
Showing 1 changed file with 18 additions and 20 deletions.
38 changes: 18 additions & 20 deletions library/std/src/panic.rs
Original file line number Diff line number Diff line change
Expand Up @@ -498,26 +498,24 @@ pub fn get_backtrace_style() -> Option<BacktraceStyle> {
// to optimize away callers.
return None;
}
BacktraceStyle::from_u8(SHOULD_CAPTURE.load(Ordering::Acquire)).map(Some).unwrap_or_else(|| {
let env_var = crate::env::var_os("RUST_BACKTRACE");
let style = env_var
.and_then(|var| {
var.to_str().map(|s| match s {
"0" => BacktraceStyle::Off,
"full" => BacktraceStyle::Full,
_ => BacktraceStyle::Short,
})
})
.unwrap_or_else(|| {
if crate::sys::FULL_BACKTRACE_DEFAULT {
BacktraceStyle::Full
} else {
BacktraceStyle::Short
}
});
set_backtrace_style(style);
Some(style)
})
if let Some(style) = BacktraceStyle::from_u8(SHOULD_CAPTURE.load(Ordering::Acquire)) {
return Some(style);
}

let format = match crate::env::var_os("RUST_BACKTRACE") {
Some(x) if &x == "0" => BacktraceStyle::Off,
Some(x) if &x == "full" => BacktraceStyle::Full,
Some(_) => BacktraceStyle::Short,
None => {
if crate::sys::FULL_BACKTRACE_DEFAULT {
BacktraceStyle::Full
} else {
BacktraceStyle::Short
}
}
};
set_backtrace_style(format);
Some(format)
}

#[cfg(test)]
Expand Down

0 comments on commit 52a29a0

Please sign in to comment.