Skip to content

Commit 5daf0a5

Browse files
oech3cakebaker
authored andcommitted
panic.rs: remove collapsible_if
1 parent 4c32ebc commit 5daf0a5

1 file changed

Lines changed: 9 additions & 14 deletions

File tree

src/uucore/src/lib/mods/panic.rs

Lines changed: 9 additions & 14 deletions
Original file line numberDiff line numberDiff line change
@@ -17,12 +17,9 @@ use std::panic::{self, PanicHookInfo};
1717

1818
/// Decide whether a panic was caused by a broken pipe (SIGPIPE) error.
1919
fn is_broken_pipe(info: &PanicHookInfo) -> bool {
20-
if let Some(res) = info.payload().downcast_ref::<String>() {
21-
if res.contains("BrokenPipe") || res.contains("Broken pipe") {
22-
return true;
23-
}
24-
}
25-
false
20+
info.payload()
21+
.downcast_ref::<String>()
22+
.is_some_and(|res| res.contains("BrokenPipe") || res.contains("Broken pipe"))
2623
}
2724

2825
/// Terminate without error on panics that occur due to broken pipe errors.
@@ -55,14 +52,12 @@ pub fn preserve_inherited_sigpipe() {
5552
use nix::libc;
5653

5754
// Check if parent specified that SIGPIPE should be default
58-
if let Ok(val) = std::env::var("RUST_SIGPIPE") {
59-
if val == "default" {
60-
unsafe {
61-
libc::signal(libc::SIGPIPE, libc::SIG_DFL);
62-
// Remove the environment variable so child processes don't inherit it incorrectly
63-
std::env::remove_var("RUST_SIGPIPE");
64-
}
65-
}
55+
if let Ok(val) = std::env::var("RUST_SIGPIPE")
56+
&& val == "default"
57+
{
58+
unsafe { libc::signal(libc::SIGPIPE, libc::SIG_DFL) };
59+
// Remove the environment variable so child processes don't inherit it incorrectly
60+
unsafe { std::env::remove_var("RUST_SIGPIPE") };
6661
}
6762
}
6863

0 commit comments

Comments
 (0)