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:
parent
b10aa47e38
commit
3b2d3716df
11 changed files with 53 additions and 77 deletions
|
@ -1153,7 +1153,7 @@ fn dd_copy(mut i: Input, o: Output) -> io::Result<()> {
|
||||||
wstat += wstat_update;
|
wstat += wstat_update;
|
||||||
match alarm.get_trigger() {
|
match alarm.get_trigger() {
|
||||||
ALARM_TRIGGER_NONE => {}
|
ALARM_TRIGGER_NONE => {}
|
||||||
t @ ALARM_TRIGGER_TIMER | t @ ALARM_TRIGGER_SIGNAL => {
|
t @ (ALARM_TRIGGER_TIMER | ALARM_TRIGGER_SIGNAL) => {
|
||||||
let tp = match t {
|
let tp = match t {
|
||||||
ALARM_TRIGGER_TIMER => ProgUpdateType::Periodic,
|
ALARM_TRIGGER_TIMER => ProgUpdateType::Periodic,
|
||||||
_ => ProgUpdateType::Signal,
|
_ => ProgUpdateType::Signal,
|
||||||
|
|
11
src/uu/env/src/split_iterator.rs
vendored
11
src/uu/env/src/split_iterator.rs
vendored
|
@ -172,12 +172,11 @@ impl<'a> SplitIterator<'a> {
|
||||||
self.get_parser().get_peek_position(),
|
self.get_parser().get_peek_position(),
|
||||||
"Delimiter".into(),
|
"Delimiter".into(),
|
||||||
)),
|
)),
|
||||||
Some('_') | Some(NEW_LINE) => {
|
Some('_' | NEW_LINE) => {
|
||||||
self.skip_one()?;
|
self.skip_one()?;
|
||||||
Ok(())
|
Ok(())
|
||||||
}
|
}
|
||||||
Some(DOLLAR) | Some(BACKSLASH) | Some('#') | Some(SINGLE_QUOTES)
|
Some(DOLLAR | BACKSLASH | '#' | SINGLE_QUOTES | DOUBLE_QUOTES) => {
|
||||||
| Some(DOUBLE_QUOTES) => {
|
|
||||||
self.take_one()?;
|
self.take_one()?;
|
||||||
self.state_unquoted()
|
self.state_unquoted()
|
||||||
}
|
}
|
||||||
|
@ -240,7 +239,7 @@ impl<'a> SplitIterator<'a> {
|
||||||
self.push_word_to_words();
|
self.push_word_to_words();
|
||||||
Err(EnvError::EnvReachedEnd)
|
Err(EnvError::EnvReachedEnd)
|
||||||
}
|
}
|
||||||
Some(DOLLAR) | Some(BACKSLASH) | Some(SINGLE_QUOTES) | Some(DOUBLE_QUOTES) => {
|
Some(DOLLAR | BACKSLASH | SINGLE_QUOTES | DOUBLE_QUOTES) => {
|
||||||
self.take_one()?;
|
self.take_one()?;
|
||||||
Ok(())
|
Ok(())
|
||||||
}
|
}
|
||||||
|
@ -283,7 +282,7 @@ impl<'a> SplitIterator<'a> {
|
||||||
self.skip_one()?;
|
self.skip_one()?;
|
||||||
Ok(())
|
Ok(())
|
||||||
}
|
}
|
||||||
Some(SINGLE_QUOTES) | Some(BACKSLASH) => {
|
Some(SINGLE_QUOTES | BACKSLASH) => {
|
||||||
self.take_one()?;
|
self.take_one()?;
|
||||||
Ok(())
|
Ok(())
|
||||||
}
|
}
|
||||||
|
@ -336,7 +335,7 @@ impl<'a> SplitIterator<'a> {
|
||||||
self.skip_one()?;
|
self.skip_one()?;
|
||||||
Ok(())
|
Ok(())
|
||||||
}
|
}
|
||||||
Some(DOUBLE_QUOTES) | Some(DOLLAR) | Some(BACKSLASH) => {
|
Some(DOUBLE_QUOTES | DOLLAR | BACKSLASH) => {
|
||||||
self.take_one()?;
|
self.take_one()?;
|
||||||
Ok(())
|
Ok(())
|
||||||
}
|
}
|
||||||
|
|
|
@ -232,7 +232,7 @@ fn check_posix_regex_errors(pattern: &str) -> ExprResult<()> {
|
||||||
// Empty repeating pattern
|
// Empty repeating pattern
|
||||||
invalid_content_error = true;
|
invalid_content_error = true;
|
||||||
}
|
}
|
||||||
(x, None) | (x, Some("")) => {
|
(x, None | Some("")) => {
|
||||||
if x.parse::<i16>().is_err() {
|
if x.parse::<i16>().is_err() {
|
||||||
invalid_content_error = true;
|
invalid_content_error = true;
|
||||||
}
|
}
|
||||||
|
|
|
@ -347,33 +347,25 @@ fn more(
|
||||||
kind: KeyEventKind::Release,
|
kind: KeyEventKind::Release,
|
||||||
..
|
..
|
||||||
}) => continue,
|
}) => continue,
|
||||||
Event::Key(KeyEvent {
|
Event::Key(
|
||||||
code: KeyCode::Char('q'),
|
KeyEvent {
|
||||||
modifiers: KeyModifiers::NONE,
|
code: KeyCode::Char('q'),
|
||||||
kind: KeyEventKind::Press,
|
modifiers: KeyModifiers::NONE,
|
||||||
..
|
kind: KeyEventKind::Press,
|
||||||
})
|
..
|
||||||
| Event::Key(KeyEvent {
|
}
|
||||||
code: KeyCode::Char('c'),
|
| KeyEvent {
|
||||||
modifiers: KeyModifiers::CONTROL,
|
code: KeyCode::Char('c'),
|
||||||
kind: KeyEventKind::Press,
|
modifiers: KeyModifiers::CONTROL,
|
||||||
..
|
kind: KeyEventKind::Press,
|
||||||
}) => {
|
..
|
||||||
|
},
|
||||||
|
) => {
|
||||||
reset_term(stdout);
|
reset_term(stdout);
|
||||||
std::process::exit(0);
|
std::process::exit(0);
|
||||||
}
|
}
|
||||||
Event::Key(KeyEvent {
|
Event::Key(KeyEvent {
|
||||||
code: KeyCode::Down,
|
code: KeyCode::Down | KeyCode::PageDown | KeyCode::Char(' '),
|
||||||
modifiers: KeyModifiers::NONE,
|
|
||||||
..
|
|
||||||
})
|
|
||||||
| Event::Key(KeyEvent {
|
|
||||||
code: KeyCode::PageDown,
|
|
||||||
modifiers: KeyModifiers::NONE,
|
|
||||||
..
|
|
||||||
})
|
|
||||||
| Event::Key(KeyEvent {
|
|
||||||
code: KeyCode::Char(' '),
|
|
||||||
modifiers: KeyModifiers::NONE,
|
modifiers: KeyModifiers::NONE,
|
||||||
..
|
..
|
||||||
}) => {
|
}) => {
|
||||||
|
@ -384,12 +376,7 @@ fn more(
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
Event::Key(KeyEvent {
|
Event::Key(KeyEvent {
|
||||||
code: KeyCode::Up,
|
code: KeyCode::Up | KeyCode::PageUp,
|
||||||
modifiers: KeyModifiers::NONE,
|
|
||||||
..
|
|
||||||
})
|
|
||||||
| Event::Key(KeyEvent {
|
|
||||||
code: KeyCode::PageUp,
|
|
||||||
modifiers: KeyModifiers::NONE,
|
modifiers: KeyModifiers::NONE,
|
||||||
..
|
..
|
||||||
}) => {
|
}) => {
|
||||||
|
|
|
@ -111,21 +111,18 @@ fn parse_implicit_precision(s: &str) -> usize {
|
||||||
|
|
||||||
fn remove_suffix(i: f64, s: Option<Suffix>, u: &Unit) -> Result<f64> {
|
fn remove_suffix(i: f64, s: Option<Suffix>, u: &Unit) -> Result<f64> {
|
||||||
match (s, u) {
|
match (s, u) {
|
||||||
(Some((raw_suffix, false)), &Unit::Auto) | (Some((raw_suffix, false)), &Unit::Si) => {
|
(Some((raw_suffix, false)), &Unit::Auto | &Unit::Si) => match raw_suffix {
|
||||||
match raw_suffix {
|
RawSuffix::K => Ok(i * 1e3),
|
||||||
RawSuffix::K => Ok(i * 1e3),
|
RawSuffix::M => Ok(i * 1e6),
|
||||||
RawSuffix::M => Ok(i * 1e6),
|
RawSuffix::G => Ok(i * 1e9),
|
||||||
RawSuffix::G => Ok(i * 1e9),
|
RawSuffix::T => Ok(i * 1e12),
|
||||||
RawSuffix::T => Ok(i * 1e12),
|
RawSuffix::P => Ok(i * 1e15),
|
||||||
RawSuffix::P => Ok(i * 1e15),
|
RawSuffix::E => Ok(i * 1e18),
|
||||||
RawSuffix::E => Ok(i * 1e18),
|
RawSuffix::Z => Ok(i * 1e21),
|
||||||
RawSuffix::Z => Ok(i * 1e21),
|
RawSuffix::Y => Ok(i * 1e24),
|
||||||
RawSuffix::Y => Ok(i * 1e24),
|
},
|
||||||
}
|
|
||||||
}
|
|
||||||
(Some((raw_suffix, false)), &Unit::Iec(false))
|
(Some((raw_suffix, false)), &Unit::Iec(false))
|
||||||
| (Some((raw_suffix, true)), &Unit::Auto)
|
| (Some((raw_suffix, true)), &Unit::Auto | &Unit::Iec(true)) => match raw_suffix {
|
||||||
| (Some((raw_suffix, true)), &Unit::Iec(true)) => match raw_suffix {
|
|
||||||
RawSuffix::K => Ok(i * IEC_BASES[1]),
|
RawSuffix::K => Ok(i * IEC_BASES[1]),
|
||||||
RawSuffix::M => Ok(i * IEC_BASES[2]),
|
RawSuffix::M => Ok(i * IEC_BASES[2]),
|
||||||
RawSuffix::G => Ok(i * IEC_BASES[3]),
|
RawSuffix::G => Ok(i * IEC_BASES[3]),
|
||||||
|
|
|
@ -372,10 +372,7 @@ impl Compare<MergeableFile> for FileComparator<'_> {
|
||||||
|
|
||||||
// Wait for the child to exit and check its exit code.
|
// Wait for the child to exit and check its exit code.
|
||||||
fn check_child_success(mut child: Child, program: &str) -> UResult<()> {
|
fn check_child_success(mut child: Child, program: &str) -> UResult<()> {
|
||||||
if matches!(
|
if matches!(child.wait().map(|e| e.code()), Ok(Some(0) | None) | Err(_)) {
|
||||||
child.wait().map(|e| e.code()),
|
|
||||||
Ok(Some(0)) | Ok(None) | Err(_)
|
|
||||||
) {
|
|
||||||
Ok(())
|
Ok(())
|
||||||
} else {
|
} else {
|
||||||
Err(SortError::CompressProgTerminatedAbnormally {
|
Err(SortError::CompressProgTerminatedAbnormally {
|
||||||
|
|
|
@ -1697,7 +1697,7 @@ fn get_leading_gen(input: &str) -> Range<usize> {
|
||||||
|
|
||||||
let first = char_indices.peek();
|
let first = char_indices.peek();
|
||||||
|
|
||||||
if matches!(first, Some((_, NEGATIVE) | (_, POSITIVE))) {
|
if matches!(first, Some((_, NEGATIVE | POSITIVE))) {
|
||||||
char_indices.next();
|
char_indices.next();
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
|
@ -516,9 +516,11 @@ impl Settings {
|
||||||
// As those are writing to stdout of `split` and cannot write to filter command child process
|
// As those are writing to stdout of `split` and cannot write to filter command child process
|
||||||
let kth_chunk = matches!(
|
let kth_chunk = matches!(
|
||||||
result.strategy,
|
result.strategy,
|
||||||
Strategy::Number(NumberType::KthBytes(_, _))
|
Strategy::Number(
|
||||||
| Strategy::Number(NumberType::KthLines(_, _))
|
NumberType::KthBytes(_, _)
|
||||||
| Strategy::Number(NumberType::KthRoundRobin(_, _))
|
| NumberType::KthLines(_, _)
|
||||||
|
| NumberType::KthRoundRobin(_, _)
|
||||||
|
)
|
||||||
);
|
);
|
||||||
if kth_chunk && result.filter.is_some() {
|
if kth_chunk && result.filter.is_some() {
|
||||||
return Err(SettingsError::FilterWithKthChunkNumber);
|
return Err(SettingsError::FilterWithKthChunkNumber);
|
||||||
|
|
|
@ -318,12 +318,10 @@ impl Observer {
|
||||||
let display_name = self.files.get(event_path).display_name.clone();
|
let display_name = self.files.get(event_path).display_name.clone();
|
||||||
|
|
||||||
match event.kind {
|
match event.kind {
|
||||||
EventKind::Modify(ModifyKind::Metadata(MetadataKind::Any | MetadataKind::WriteTime))
|
EventKind::Modify(ModifyKind::Metadata(MetadataKind::Any |
|
||||||
|
MetadataKind::WriteTime) | ModifyKind::Data(DataChange::Any) |
|
||||||
// | EventKind::Access(AccessKind::Close(AccessMode::Write))
|
ModifyKind::Name(RenameMode::To)) |
|
||||||
| EventKind::Create(CreateKind::File | CreateKind::Folder | CreateKind::Any)
|
EventKind::Create(CreateKind::File | CreateKind::Folder | CreateKind::Any) => {
|
||||||
| EventKind::Modify(ModifyKind::Data(DataChange::Any))
|
|
||||||
| EventKind::Modify(ModifyKind::Name(RenameMode::To)) => {
|
|
||||||
if let Ok(new_md) = event_path.metadata() {
|
if let Ok(new_md) = event_path.metadata() {
|
||||||
|
|
||||||
let is_tailable = new_md.is_tailable();
|
let is_tailable = new_md.is_tailable();
|
||||||
|
|
|
@ -79,11 +79,8 @@ impl Symbol {
|
||||||
Self::Bang => OsString::from("!"),
|
Self::Bang => OsString::from("!"),
|
||||||
Self::BoolOp(s)
|
Self::BoolOp(s)
|
||||||
| Self::Literal(s)
|
| Self::Literal(s)
|
||||||
| Self::Op(Operator::String(s))
|
| Self::Op(Operator::String(s) | Operator::Int(s) | Operator::File(s))
|
||||||
| Self::Op(Operator::Int(s))
|
| Self::UnaryOp(UnaryOperator::StrlenOp(s) | UnaryOperator::FiletestOp(s)) => s,
|
||||||
| Self::Op(Operator::File(s))
|
|
||||||
| Self::UnaryOp(UnaryOperator::StrlenOp(s))
|
|
||||||
| Self::UnaryOp(UnaryOperator::FiletestOp(s)) => s,
|
|
||||||
Self::None => panic!(),
|
Self::None => panic!(),
|
||||||
})
|
})
|
||||||
}
|
}
|
||||||
|
@ -99,11 +96,10 @@ impl std::fmt::Display for Symbol {
|
||||||
Self::Bang => OsStr::new("!"),
|
Self::Bang => OsStr::new("!"),
|
||||||
Self::BoolOp(s)
|
Self::BoolOp(s)
|
||||||
| Self::Literal(s)
|
| Self::Literal(s)
|
||||||
| Self::Op(Operator::String(s))
|
| Self::Op(Operator::String(s) | Operator::Int(s) | Operator::File(s))
|
||||||
| Self::Op(Operator::Int(s))
|
| Self::UnaryOp(UnaryOperator::StrlenOp(s) | UnaryOperator::FiletestOp(s)) => {
|
||||||
| Self::Op(Operator::File(s))
|
OsStr::new(s)
|
||||||
| Self::UnaryOp(UnaryOperator::StrlenOp(s))
|
}
|
||||||
| Self::UnaryOp(UnaryOperator::FiletestOp(s)) => OsStr::new(s),
|
|
||||||
Self::None => OsStr::new("None"),
|
Self::None => OsStr::new("None"),
|
||||||
};
|
};
|
||||||
write!(f, "{}", s.quote())
|
write!(f, "{}", s.quote())
|
||||||
|
|
|
@ -204,7 +204,7 @@ impl Sequence {
|
||||||
if translating
|
if translating
|
||||||
&& set2.iter().any(|&x| {
|
&& set2.iter().any(|&x| {
|
||||||
matches!(x, Self::Class(_))
|
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);
|
return Err(BadSequence::ClassExceptLowerUpperInSet2);
|
||||||
|
@ -290,7 +290,7 @@ impl Sequence {
|
||||||
&& !truncate_set1_flag
|
&& !truncate_set1_flag
|
||||||
&& matches!(
|
&& matches!(
|
||||||
set2.last().copied(),
|
set2.last().copied(),
|
||||||
Some(Self::Class(Class::Upper)) | Some(Self::Class(Class::Lower))
|
Some(Self::Class(Class::Upper | Class::Lower))
|
||||||
)
|
)
|
||||||
{
|
{
|
||||||
return Err(BadSequence::Set1LongerSet2EndsInClass);
|
return Err(BadSequence::Set1LongerSet2EndsInClass);
|
||||||
|
|
Loading…
Add table
Add a link
Reference in a new issue