1
Fork 0
mirror of https://github.com/RGBCube/uutils-coreutils synced 2025-07-28 11:37:44 +00:00

chore: fix clippy::unnested_or_patterns

Used this command:

```shell
cargo clippy --fix --workspace --all-targets -- -A clippy::all -W clippy::unnested_or_patterns
cargo fmt --all
```
This commit is contained in:
Yuri Astrakhan 2025-04-11 18:00:07 -04:00
parent b10aa47e38
commit 3b2d3716df
11 changed files with 53 additions and 77 deletions

View file

@ -1153,7 +1153,7 @@ fn dd_copy(mut i: Input, o: Output) -> io::Result<()> {
wstat += wstat_update;
match alarm.get_trigger() {
ALARM_TRIGGER_NONE => {}
t @ ALARM_TRIGGER_TIMER | t @ ALARM_TRIGGER_SIGNAL => {
t @ (ALARM_TRIGGER_TIMER | ALARM_TRIGGER_SIGNAL) => {
let tp = match t {
ALARM_TRIGGER_TIMER => ProgUpdateType::Periodic,
_ => ProgUpdateType::Signal,

View file

@ -172,12 +172,11 @@ impl<'a> SplitIterator<'a> {
self.get_parser().get_peek_position(),
"Delimiter".into(),
)),
Some('_') | Some(NEW_LINE) => {
Some('_' | NEW_LINE) => {
self.skip_one()?;
Ok(())
}
Some(DOLLAR) | Some(BACKSLASH) | Some('#') | Some(SINGLE_QUOTES)
| Some(DOUBLE_QUOTES) => {
Some(DOLLAR | BACKSLASH | '#' | SINGLE_QUOTES | DOUBLE_QUOTES) => {
self.take_one()?;
self.state_unquoted()
}
@ -240,7 +239,7 @@ impl<'a> SplitIterator<'a> {
self.push_word_to_words();
Err(EnvError::EnvReachedEnd)
}
Some(DOLLAR) | Some(BACKSLASH) | Some(SINGLE_QUOTES) | Some(DOUBLE_QUOTES) => {
Some(DOLLAR | BACKSLASH | SINGLE_QUOTES | DOUBLE_QUOTES) => {
self.take_one()?;
Ok(())
}
@ -283,7 +282,7 @@ impl<'a> SplitIterator<'a> {
self.skip_one()?;
Ok(())
}
Some(SINGLE_QUOTES) | Some(BACKSLASH) => {
Some(SINGLE_QUOTES | BACKSLASH) => {
self.take_one()?;
Ok(())
}
@ -336,7 +335,7 @@ impl<'a> SplitIterator<'a> {
self.skip_one()?;
Ok(())
}
Some(DOUBLE_QUOTES) | Some(DOLLAR) | Some(BACKSLASH) => {
Some(DOUBLE_QUOTES | DOLLAR | BACKSLASH) => {
self.take_one()?;
Ok(())
}

View file

@ -232,7 +232,7 @@ fn check_posix_regex_errors(pattern: &str) -> ExprResult<()> {
// Empty repeating pattern
invalid_content_error = true;
}
(x, None) | (x, Some("")) => {
(x, None | Some("")) => {
if x.parse::<i16>().is_err() {
invalid_content_error = true;
}

View file

@ -347,33 +347,25 @@ fn more(
kind: KeyEventKind::Release,
..
}) => continue,
Event::Key(KeyEvent {
code: KeyCode::Char('q'),
modifiers: KeyModifiers::NONE,
kind: KeyEventKind::Press,
..
})
| Event::Key(KeyEvent {
code: KeyCode::Char('c'),
modifiers: KeyModifiers::CONTROL,
kind: KeyEventKind::Press,
..
}) => {
Event::Key(
KeyEvent {
code: KeyCode::Char('q'),
modifiers: KeyModifiers::NONE,
kind: KeyEventKind::Press,
..
}
| KeyEvent {
code: KeyCode::Char('c'),
modifiers: KeyModifiers::CONTROL,
kind: KeyEventKind::Press,
..
},
) => {
reset_term(stdout);
std::process::exit(0);
}
Event::Key(KeyEvent {
code: KeyCode::Down,
modifiers: KeyModifiers::NONE,
..
})
| Event::Key(KeyEvent {
code: KeyCode::PageDown,
modifiers: KeyModifiers::NONE,
..
})
| Event::Key(KeyEvent {
code: KeyCode::Char(' '),
code: KeyCode::Down | KeyCode::PageDown | KeyCode::Char(' '),
modifiers: KeyModifiers::NONE,
..
}) => {
@ -384,12 +376,7 @@ fn more(
}
}
Event::Key(KeyEvent {
code: KeyCode::Up,
modifiers: KeyModifiers::NONE,
..
})
| Event::Key(KeyEvent {
code: KeyCode::PageUp,
code: KeyCode::Up | KeyCode::PageUp,
modifiers: KeyModifiers::NONE,
..
}) => {

View file

@ -111,21 +111,18 @@ fn parse_implicit_precision(s: &str) -> usize {
fn remove_suffix(i: f64, s: Option<Suffix>, u: &Unit) -> Result<f64> {
match (s, u) {
(Some((raw_suffix, false)), &Unit::Auto) | (Some((raw_suffix, false)), &Unit::Si) => {
match raw_suffix {
RawSuffix::K => Ok(i * 1e3),
RawSuffix::M => Ok(i * 1e6),
RawSuffix::G => Ok(i * 1e9),
RawSuffix::T => Ok(i * 1e12),
RawSuffix::P => Ok(i * 1e15),
RawSuffix::E => Ok(i * 1e18),
RawSuffix::Z => Ok(i * 1e21),
RawSuffix::Y => Ok(i * 1e24),
}
}
(Some((raw_suffix, false)), &Unit::Auto | &Unit::Si) => match raw_suffix {
RawSuffix::K => Ok(i * 1e3),
RawSuffix::M => Ok(i * 1e6),
RawSuffix::G => Ok(i * 1e9),
RawSuffix::T => Ok(i * 1e12),
RawSuffix::P => Ok(i * 1e15),
RawSuffix::E => Ok(i * 1e18),
RawSuffix::Z => Ok(i * 1e21),
RawSuffix::Y => Ok(i * 1e24),
},
(Some((raw_suffix, false)), &Unit::Iec(false))
| (Some((raw_suffix, true)), &Unit::Auto)
| (Some((raw_suffix, true)), &Unit::Iec(true)) => match raw_suffix {
| (Some((raw_suffix, true)), &Unit::Auto | &Unit::Iec(true)) => match raw_suffix {
RawSuffix::K => Ok(i * IEC_BASES[1]),
RawSuffix::M => Ok(i * IEC_BASES[2]),
RawSuffix::G => Ok(i * IEC_BASES[3]),

View file

@ -372,10 +372,7 @@ impl Compare<MergeableFile> for FileComparator<'_> {
// Wait for the child to exit and check its exit code.
fn check_child_success(mut child: Child, program: &str) -> UResult<()> {
if matches!(
child.wait().map(|e| e.code()),
Ok(Some(0)) | Ok(None) | Err(_)
) {
if matches!(child.wait().map(|e| e.code()), Ok(Some(0) | None) | Err(_)) {
Ok(())
} else {
Err(SortError::CompressProgTerminatedAbnormally {

View file

@ -1697,7 +1697,7 @@ fn get_leading_gen(input: &str) -> Range<usize> {
let first = char_indices.peek();
if matches!(first, Some((_, NEGATIVE) | (_, POSITIVE))) {
if matches!(first, Some((_, NEGATIVE | POSITIVE))) {
char_indices.next();
}

View file

@ -516,9 +516,11 @@ impl Settings {
// As those are writing to stdout of `split` and cannot write to filter command child process
let kth_chunk = matches!(
result.strategy,
Strategy::Number(NumberType::KthBytes(_, _))
| Strategy::Number(NumberType::KthLines(_, _))
| Strategy::Number(NumberType::KthRoundRobin(_, _))
Strategy::Number(
NumberType::KthBytes(_, _)
| NumberType::KthLines(_, _)
| NumberType::KthRoundRobin(_, _)
)
);
if kth_chunk && result.filter.is_some() {
return Err(SettingsError::FilterWithKthChunkNumber);

View file

@ -318,12 +318,10 @@ impl Observer {
let display_name = self.files.get(event_path).display_name.clone();
match event.kind {
EventKind::Modify(ModifyKind::Metadata(MetadataKind::Any | MetadataKind::WriteTime))
// | EventKind::Access(AccessKind::Close(AccessMode::Write))
| EventKind::Create(CreateKind::File | CreateKind::Folder | CreateKind::Any)
| EventKind::Modify(ModifyKind::Data(DataChange::Any))
| EventKind::Modify(ModifyKind::Name(RenameMode::To)) => {
EventKind::Modify(ModifyKind::Metadata(MetadataKind::Any |
MetadataKind::WriteTime) | ModifyKind::Data(DataChange::Any) |
ModifyKind::Name(RenameMode::To)) |
EventKind::Create(CreateKind::File | CreateKind::Folder | CreateKind::Any) => {
if let Ok(new_md) = event_path.metadata() {
let is_tailable = new_md.is_tailable();

View file

@ -79,11 +79,8 @@ impl Symbol {
Self::Bang => OsString::from("!"),
Self::BoolOp(s)
| Self::Literal(s)
| Self::Op(Operator::String(s))
| Self::Op(Operator::Int(s))
| Self::Op(Operator::File(s))
| Self::UnaryOp(UnaryOperator::StrlenOp(s))
| Self::UnaryOp(UnaryOperator::FiletestOp(s)) => s,
| Self::Op(Operator::String(s) | Operator::Int(s) | Operator::File(s))
| Self::UnaryOp(UnaryOperator::StrlenOp(s) | UnaryOperator::FiletestOp(s)) => s,
Self::None => panic!(),
})
}
@ -99,11 +96,10 @@ impl std::fmt::Display for Symbol {
Self::Bang => OsStr::new("!"),
Self::BoolOp(s)
| Self::Literal(s)
| Self::Op(Operator::String(s))
| Self::Op(Operator::Int(s))
| Self::Op(Operator::File(s))
| Self::UnaryOp(UnaryOperator::StrlenOp(s))
| Self::UnaryOp(UnaryOperator::FiletestOp(s)) => OsStr::new(s),
| Self::Op(Operator::String(s) | Operator::Int(s) | Operator::File(s))
| Self::UnaryOp(UnaryOperator::StrlenOp(s) | UnaryOperator::FiletestOp(s)) => {
OsStr::new(s)
}
Self::None => OsStr::new("None"),
};
write!(f, "{}", s.quote())

View file

@ -204,7 +204,7 @@ impl Sequence {
if translating
&& set2.iter().any(|&x| {
matches!(x, Self::Class(_))
&& !matches!(x, Self::Class(Class::Upper) | Self::Class(Class::Lower))
&& !matches!(x, Self::Class(Class::Upper | Class::Lower))
})
{
return Err(BadSequence::ClassExceptLowerUpperInSet2);
@ -290,7 +290,7 @@ impl Sequence {
&& !truncate_set1_flag
&& matches!(
set2.last().copied(),
Some(Self::Class(Class::Upper)) | Some(Self::Class(Class::Lower))
Some(Self::Class(Class::Upper | Class::Lower))
)
{
return Err(BadSequence::Set1LongerSet2EndsInClass);