Skip to content

Commit e1645bb

Browse files
authored
Merge pull request #7730 from nyurik/unnested_or_patterns
chore: fix `clippy::unnested_or_patterns`
2 parents 3d99430 + 3b2d371 commit e1645bb

File tree

11 files changed

+53
-77
lines changed

11 files changed

+53
-77
lines changed

src/uu/dd/src/dd.rs

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1153,7 +1153,7 @@ fn dd_copy(mut i: Input, o: Output) -> io::Result<()> {
11531153
wstat += wstat_update;
11541154
match alarm.get_trigger() {
11551155
ALARM_TRIGGER_NONE => {}
1156-
t @ ALARM_TRIGGER_TIMER | t @ ALARM_TRIGGER_SIGNAL => {
1156+
t @ (ALARM_TRIGGER_TIMER | ALARM_TRIGGER_SIGNAL) => {
11571157
let tp = match t {
11581158
ALARM_TRIGGER_TIMER => ProgUpdateType::Periodic,
11591159
_ => ProgUpdateType::Signal,

src/uu/env/src/split_iterator.rs

Lines changed: 5 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -172,12 +172,11 @@ impl<'a> SplitIterator<'a> {
172172
self.get_parser().get_peek_position(),
173173
"Delimiter".into(),
174174
)),
175-
Some('_') | Some(NEW_LINE) => {
175+
Some('_' | NEW_LINE) => {
176176
self.skip_one()?;
177177
Ok(())
178178
}
179-
Some(DOLLAR) | Some(BACKSLASH) | Some('#') | Some(SINGLE_QUOTES)
180-
| Some(DOUBLE_QUOTES) => {
179+
Some(DOLLAR | BACKSLASH | '#' | SINGLE_QUOTES | DOUBLE_QUOTES) => {
181180
self.take_one()?;
182181
self.state_unquoted()
183182
}
@@ -240,7 +239,7 @@ impl<'a> SplitIterator<'a> {
240239
self.push_word_to_words();
241240
Err(EnvError::EnvReachedEnd)
242241
}
243-
Some(DOLLAR) | Some(BACKSLASH) | Some(SINGLE_QUOTES) | Some(DOUBLE_QUOTES) => {
242+
Some(DOLLAR | BACKSLASH | SINGLE_QUOTES | DOUBLE_QUOTES) => {
244243
self.take_one()?;
245244
Ok(())
246245
}
@@ -283,7 +282,7 @@ impl<'a> SplitIterator<'a> {
283282
self.skip_one()?;
284283
Ok(())
285284
}
286-
Some(SINGLE_QUOTES) | Some(BACKSLASH) => {
285+
Some(SINGLE_QUOTES | BACKSLASH) => {
287286
self.take_one()?;
288287
Ok(())
289288
}
@@ -336,7 +335,7 @@ impl<'a> SplitIterator<'a> {
336335
self.skip_one()?;
337336
Ok(())
338337
}
339-
Some(DOUBLE_QUOTES) | Some(DOLLAR) | Some(BACKSLASH) => {
338+
Some(DOUBLE_QUOTES | DOLLAR | BACKSLASH) => {
340339
self.take_one()?;
341340
Ok(())
342341
}

src/uu/expr/src/syntax_tree.rs

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -232,7 +232,7 @@ fn check_posix_regex_errors(pattern: &str) -> ExprResult<()> {
232232
// Empty repeating pattern
233233
invalid_content_error = true;
234234
}
235-
(x, None) | (x, Some("")) => {
235+
(x, None | Some("")) => {
236236
if x.parse::<i16>().is_err() {
237237
invalid_content_error = true;
238238
}

src/uu/more/src/more.rs

Lines changed: 16 additions & 29 deletions
Original file line numberDiff line numberDiff line change
@@ -347,33 +347,25 @@ fn more(
347347
kind: KeyEventKind::Release,
348348
..
349349
}) => continue,
350-
Event::Key(KeyEvent {
351-
code: KeyCode::Char('q'),
352-
modifiers: KeyModifiers::NONE,
353-
kind: KeyEventKind::Press,
354-
..
355-
})
356-
| Event::Key(KeyEvent {
357-
code: KeyCode::Char('c'),
358-
modifiers: KeyModifiers::CONTROL,
359-
kind: KeyEventKind::Press,
360-
..
361-
}) => {
350+
Event::Key(
351+
KeyEvent {
352+
code: KeyCode::Char('q'),
353+
modifiers: KeyModifiers::NONE,
354+
kind: KeyEventKind::Press,
355+
..
356+
}
357+
| KeyEvent {
358+
code: KeyCode::Char('c'),
359+
modifiers: KeyModifiers::CONTROL,
360+
kind: KeyEventKind::Press,
361+
..
362+
},
363+
) => {
362364
reset_term(stdout);
363365
std::process::exit(0);
364366
}
365367
Event::Key(KeyEvent {
366-
code: KeyCode::Down,
367-
modifiers: KeyModifiers::NONE,
368-
..
369-
})
370-
| Event::Key(KeyEvent {
371-
code: KeyCode::PageDown,
372-
modifiers: KeyModifiers::NONE,
373-
..
374-
})
375-
| Event::Key(KeyEvent {
376-
code: KeyCode::Char(' '),
368+
code: KeyCode::Down | KeyCode::PageDown | KeyCode::Char(' '),
377369
modifiers: KeyModifiers::NONE,
378370
..
379371
}) => {
@@ -384,12 +376,7 @@ fn more(
384376
}
385377
}
386378
Event::Key(KeyEvent {
387-
code: KeyCode::Up,
388-
modifiers: KeyModifiers::NONE,
389-
..
390-
})
391-
| Event::Key(KeyEvent {
392-
code: KeyCode::PageUp,
379+
code: KeyCode::Up | KeyCode::PageUp,
393380
modifiers: KeyModifiers::NONE,
394381
..
395382
}) => {

src/uu/numfmt/src/format.rs

Lines changed: 11 additions & 14 deletions
Original file line numberDiff line numberDiff line change
@@ -111,21 +111,18 @@ fn parse_implicit_precision(s: &str) -> usize {
111111

112112
fn remove_suffix(i: f64, s: Option<Suffix>, u: &Unit) -> Result<f64> {
113113
match (s, u) {
114-
(Some((raw_suffix, false)), &Unit::Auto) | (Some((raw_suffix, false)), &Unit::Si) => {
115-
match raw_suffix {
116-
RawSuffix::K => Ok(i * 1e3),
117-
RawSuffix::M => Ok(i * 1e6),
118-
RawSuffix::G => Ok(i * 1e9),
119-
RawSuffix::T => Ok(i * 1e12),
120-
RawSuffix::P => Ok(i * 1e15),
121-
RawSuffix::E => Ok(i * 1e18),
122-
RawSuffix::Z => Ok(i * 1e21),
123-
RawSuffix::Y => Ok(i * 1e24),
124-
}
125-
}
114+
(Some((raw_suffix, false)), &Unit::Auto | &Unit::Si) => match raw_suffix {
115+
RawSuffix::K => Ok(i * 1e3),
116+
RawSuffix::M => Ok(i * 1e6),
117+
RawSuffix::G => Ok(i * 1e9),
118+
RawSuffix::T => Ok(i * 1e12),
119+
RawSuffix::P => Ok(i * 1e15),
120+
RawSuffix::E => Ok(i * 1e18),
121+
RawSuffix::Z => Ok(i * 1e21),
122+
RawSuffix::Y => Ok(i * 1e24),
123+
},
126124
(Some((raw_suffix, false)), &Unit::Iec(false))
127-
| (Some((raw_suffix, true)), &Unit::Auto)
128-
| (Some((raw_suffix, true)), &Unit::Iec(true)) => match raw_suffix {
125+
| (Some((raw_suffix, true)), &Unit::Auto | &Unit::Iec(true)) => match raw_suffix {
129126
RawSuffix::K => Ok(i * IEC_BASES[1]),
130127
RawSuffix::M => Ok(i * IEC_BASES[2]),
131128
RawSuffix::G => Ok(i * IEC_BASES[3]),

src/uu/sort/src/merge.rs

Lines changed: 1 addition & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -372,10 +372,7 @@ impl Compare<MergeableFile> for FileComparator<'_> {
372372

373373
// Wait for the child to exit and check its exit code.
374374
fn check_child_success(mut child: Child, program: &str) -> UResult<()> {
375-
if matches!(
376-
child.wait().map(|e| e.code()),
377-
Ok(Some(0)) | Ok(None) | Err(_)
378-
) {
375+
if matches!(child.wait().map(|e| e.code()), Ok(Some(0) | None) | Err(_)) {
379376
Ok(())
380377
} else {
381378
Err(SortError::CompressProgTerminatedAbnormally {

src/uu/sort/src/sort.rs

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1697,7 +1697,7 @@ fn get_leading_gen(input: &str) -> Range<usize> {
16971697

16981698
let first = char_indices.peek();
16991699

1700-
if matches!(first, Some((_, NEGATIVE) | (_, POSITIVE))) {
1700+
if matches!(first, Some((_, NEGATIVE | POSITIVE))) {
17011701
char_indices.next();
17021702
}
17031703

src/uu/split/src/split.rs

Lines changed: 5 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -516,9 +516,11 @@ impl Settings {
516516
// As those are writing to stdout of `split` and cannot write to filter command child process
517517
let kth_chunk = matches!(
518518
result.strategy,
519-
Strategy::Number(NumberType::KthBytes(_, _))
520-
| Strategy::Number(NumberType::KthLines(_, _))
521-
| Strategy::Number(NumberType::KthRoundRobin(_, _))
519+
Strategy::Number(
520+
NumberType::KthBytes(_, _)
521+
| NumberType::KthLines(_, _)
522+
| NumberType::KthRoundRobin(_, _)
523+
)
522524
);
523525
if kth_chunk && result.filter.is_some() {
524526
return Err(SettingsError::FilterWithKthChunkNumber);

src/uu/tail/src/follow/watch.rs

Lines changed: 4 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -318,12 +318,10 @@ impl Observer {
318318
let display_name = self.files.get(event_path).display_name.clone();
319319

320320
match event.kind {
321-
EventKind::Modify(ModifyKind::Metadata(MetadataKind::Any | MetadataKind::WriteTime))
322-
323-
// | EventKind::Access(AccessKind::Close(AccessMode::Write))
324-
| EventKind::Create(CreateKind::File | CreateKind::Folder | CreateKind::Any)
325-
| EventKind::Modify(ModifyKind::Data(DataChange::Any))
326-
| EventKind::Modify(ModifyKind::Name(RenameMode::To)) => {
321+
EventKind::Modify(ModifyKind::Metadata(MetadataKind::Any |
322+
MetadataKind::WriteTime) | ModifyKind::Data(DataChange::Any) |
323+
ModifyKind::Name(RenameMode::To)) |
324+
EventKind::Create(CreateKind::File | CreateKind::Folder | CreateKind::Any) => {
327325
if let Ok(new_md) = event_path.metadata() {
328326

329327
let is_tailable = new_md.is_tailable();

src/uu/test/src/parser.rs

Lines changed: 6 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -79,11 +79,8 @@ impl Symbol {
7979
Self::Bang => OsString::from("!"),
8080
Self::BoolOp(s)
8181
| Self::Literal(s)
82-
| Self::Op(Operator::String(s))
83-
| Self::Op(Operator::Int(s))
84-
| Self::Op(Operator::File(s))
85-
| Self::UnaryOp(UnaryOperator::StrlenOp(s))
86-
| Self::UnaryOp(UnaryOperator::FiletestOp(s)) => s,
82+
| Self::Op(Operator::String(s) | Operator::Int(s) | Operator::File(s))
83+
| Self::UnaryOp(UnaryOperator::StrlenOp(s) | UnaryOperator::FiletestOp(s)) => s,
8784
Self::None => panic!(),
8885
})
8986
}
@@ -99,11 +96,10 @@ impl std::fmt::Display for Symbol {
9996
Self::Bang => OsStr::new("!"),
10097
Self::BoolOp(s)
10198
| Self::Literal(s)
102-
| Self::Op(Operator::String(s))
103-
| Self::Op(Operator::Int(s))
104-
| Self::Op(Operator::File(s))
105-
| Self::UnaryOp(UnaryOperator::StrlenOp(s))
106-
| Self::UnaryOp(UnaryOperator::FiletestOp(s)) => OsStr::new(s),
99+
| Self::Op(Operator::String(s) | Operator::Int(s) | Operator::File(s))
100+
| Self::UnaryOp(UnaryOperator::StrlenOp(s) | UnaryOperator::FiletestOp(s)) => {
101+
OsStr::new(s)
102+
}
107103
Self::None => OsStr::new("None"),
108104
};
109105
write!(f, "{}", s.quote())

0 commit comments

Comments
 (0)