Skip to content

Commit ed8689e

Browse files
authored
Merge pull request #7700 from nyurik/parens
chore: remove unneeded parens
2 parents 75a04c9 + d77470b commit ed8689e

File tree

12 files changed

+43
-46
lines changed

12 files changed

+43
-46
lines changed

src/bin/coreutils.rs

Lines changed: 4 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -65,7 +65,7 @@ fn main() {
6565

6666
// binary name equals util name?
6767
if let Some(&(uumain, _)) = utils.get(binary_as_util) {
68-
process::exit(uumain((vec![binary.into()].into_iter()).chain(args)));
68+
process::exit(uumain(vec![binary.into()].into_iter().chain(args)));
6969
}
7070

7171
// binary name equals prefixed util name?
@@ -111,7 +111,7 @@ fn main() {
111111

112112
match utils.get(util) {
113113
Some(&(uumain, _)) => {
114-
process::exit(uumain((vec![util_os].into_iter()).chain(args)));
114+
process::exit(uumain(vec![util_os].into_iter().chain(args)));
115115
}
116116
None => {
117117
if util == "--help" || util == "-h" {
@@ -124,7 +124,8 @@ fn main() {
124124
match utils.get(util) {
125125
Some(&(uumain, _)) => {
126126
let code = uumain(
127-
(vec![util_os, OsString::from("--help")].into_iter())
127+
vec![util_os, OsString::from("--help")]
128+
.into_iter()
128129
.chain(args),
129130
);
130131
io::stdout().flush().expect("could not flush stdout");

src/uu/env/src/env.rs

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -160,7 +160,7 @@ fn parse_signal_opt<'a>(opts: &mut Options<'a>, opt: &'a OsStr) -> UResult<()> {
160160

161161
let mut sig_vec = Vec::with_capacity(signals.len());
162162
signals.into_iter().for_each(|sig| {
163-
if !(sig.is_empty()) {
163+
if !sig.is_empty() {
164164
sig_vec.push(sig);
165165
}
166166
});

src/uu/ls/src/ls.rs

Lines changed: 3 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -2392,11 +2392,9 @@ fn display_dir_entry_size(
23922392
// TODO: Cache/memorize the display_* results so we don't have to recalculate them.
23932393
if let Some(md) = entry.get_metadata(out) {
23942394
let (size_len, major_len, minor_len) = match display_len_or_rdev(md, config) {
2395-
SizeOrDeviceId::Device(major, minor) => (
2396-
(major.len() + minor.len() + 2usize),
2397-
major.len(),
2398-
minor.len(),
2399-
),
2395+
SizeOrDeviceId::Device(major, minor) => {
2396+
(major.len() + minor.len() + 2usize, major.len(), minor.len())
2397+
}
24002398
SizeOrDeviceId::Size(size) => (size.len(), 0usize, 0usize),
24012399
};
24022400
(

src/uu/pr/src/pr.rs

Lines changed: 1 addition & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -655,8 +655,7 @@ fn build_options(
655655

656656
let page_length_le_ht = page_length < (HEADER_LINES_PER_PAGE + TRAILER_LINES_PER_PAGE);
657657

658-
let display_header_and_trailer =
659-
!(page_length_le_ht) && !matches.get_flag(options::OMIT_HEADER);
658+
let display_header_and_trailer = !page_length_le_ht && !matches.get_flag(options::OMIT_HEADER);
660659

661660
let content_lines_per_page = if page_length_le_ht {
662661
page_length

src/uu/ptx/src/ptx.rs

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -323,7 +323,7 @@ fn create_word_set(config: &Config, filter: &WordFilter, file_map: &FileMap) ->
323323
continue;
324324
}
325325
let mut word = line[beg..end].to_owned();
326-
if filter.only_specified && !(filter.only_set.contains(&word)) {
326+
if filter.only_specified && !filter.only_set.contains(&word) {
327327
continue;
328328
}
329329
if filter.ignore_specified && filter.ignore_set.contains(&word) {

src/uu/tail/src/chunks.rs

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -289,7 +289,7 @@ impl BytesChunkBuffer {
289289
let mut chunk = Box::new(BytesChunk::new());
290290

291291
// fill chunks with all bytes from reader and reuse already instantiated chunks if possible
292-
while (chunk.fill(reader)?).is_some() {
292+
while chunk.fill(reader)?.is_some() {
293293
self.bytes += chunk.bytes as u64;
294294
self.chunks.push_back(chunk);
295295

@@ -565,7 +565,7 @@ impl LinesChunkBuffer {
565565
pub fn fill(&mut self, reader: &mut impl BufRead) -> UResult<()> {
566566
let mut chunk = Box::new(LinesChunk::new(self.delimiter));
567567

568-
while (chunk.fill(reader)?).is_some() {
568+
while chunk.fill(reader)?.is_some() {
569569
self.lines += chunk.lines as u64;
570570
self.chunks.push_back(chunk);
571571

src/uu/tail/src/tail.rs

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -136,7 +136,7 @@ fn tail_file(
136136
msg
137137
);
138138
}
139-
if !(observer.follow_name_retry()) {
139+
if !observer.follow_name_retry() {
140140
// skip directory if not retry
141141
return Ok(());
142142
}

src/uucore/src/lib/features/parser/parse_size.rs

Lines changed: 8 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -512,23 +512,23 @@ mod tests {
512512

513513
for &(c, exp) in &suffixes {
514514
let s = format!("2{c}B"); // KB
515-
assert_eq!(Ok(2 * (1000_u128).pow(exp)), parse_size_u128(&s));
515+
assert_eq!(Ok(2 * 1000_u128.pow(exp)), parse_size_u128(&s));
516516
let s = format!("2{c}"); // K
517-
assert_eq!(Ok(2 * (1024_u128).pow(exp)), parse_size_u128(&s));
517+
assert_eq!(Ok(2 * 1024_u128.pow(exp)), parse_size_u128(&s));
518518
let s = format!("2{c}iB"); // KiB
519-
assert_eq!(Ok(2 * (1024_u128).pow(exp)), parse_size_u128(&s));
519+
assert_eq!(Ok(2 * 1024_u128.pow(exp)), parse_size_u128(&s));
520520
let s = format!("2{}iB", c.to_lowercase()); // kiB
521-
assert_eq!(Ok(2 * (1024_u128).pow(exp)), parse_size_u128(&s));
521+
assert_eq!(Ok(2 * 1024_u128.pow(exp)), parse_size_u128(&s));
522522

523523
// suffix only
524524
let s = format!("{c}B"); // KB
525-
assert_eq!(Ok((1000_u128).pow(exp)), parse_size_u128(&s));
525+
assert_eq!(Ok(1000_u128.pow(exp)), parse_size_u128(&s));
526526
let s = format!("{c}"); // K
527-
assert_eq!(Ok((1024_u128).pow(exp)), parse_size_u128(&s));
527+
assert_eq!(Ok(1024_u128.pow(exp)), parse_size_u128(&s));
528528
let s = format!("{c}iB"); // KiB
529-
assert_eq!(Ok((1024_u128).pow(exp)), parse_size_u128(&s));
529+
assert_eq!(Ok(1024_u128.pow(exp)), parse_size_u128(&s));
530530
let s = format!("{}iB", c.to_lowercase()); // kiB
531-
assert_eq!(Ok((1024_u128).pow(exp)), parse_size_u128(&s));
531+
assert_eq!(Ok(1024_u128.pow(exp)), parse_size_u128(&s));
532532
}
533533
}
534534

src/uucore/src/lib/mods/error.rs

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -474,7 +474,7 @@ pub trait FromIo<T> {
474474
impl FromIo<Box<UIoError>> for std::io::Error {
475475
fn map_err_context(self, context: impl FnOnce() -> String) -> Box<UIoError> {
476476
Box::new(UIoError {
477-
context: Some((context)()),
477+
context: Some(context()),
478478
inner: self,
479479
})
480480
}
@@ -489,7 +489,7 @@ impl<T> FromIo<UResult<T>> for std::io::Result<T> {
489489
impl FromIo<Box<UIoError>> for std::io::ErrorKind {
490490
fn map_err_context(self, context: impl FnOnce() -> String) -> Box<UIoError> {
491491
Box::new(UIoError {
492-
context: Some((context)()),
492+
context: Some(context()),
493493
inner: std::io::Error::new(self, ""),
494494
})
495495
}
@@ -530,7 +530,7 @@ impl<T> FromIo<UResult<T>> for Result<T, nix::Error> {
530530
fn map_err_context(self, context: impl FnOnce() -> String) -> UResult<T> {
531531
self.map_err(|e| {
532532
Box::new(UIoError {
533-
context: Some((context)()),
533+
context: Some(context()),
534534
inner: std::io::Error::from_raw_os_error(e as i32),
535535
}) as Box<dyn UError>
536536
})
@@ -541,7 +541,7 @@ impl<T> FromIo<UResult<T>> for Result<T, nix::Error> {
541541
impl<T> FromIo<UResult<T>> for nix::Error {
542542
fn map_err_context(self, context: impl FnOnce() -> String) -> UResult<T> {
543543
Err(Box::new(UIoError {
544-
context: Some((context)()),
544+
context: Some(context()),
545545
inner: std::io::Error::from_raw_os_error(self as i32),
546546
}) as Box<dyn UError>)
547547
}

tests/by-util/test_cp.rs

Lines changed: 1 addition & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -5787,11 +5787,7 @@ fn test_dir_perm_race_with_preserve_mode_and_ownership() {
57875787
} else {
57885788
libc::S_IRWXG | libc::S_IRWXO
57895789
} as u32;
5790-
assert_eq!(
5791-
(mode & mask),
5792-
0,
5793-
"unwanted permissions are present - {attr}"
5794-
);
5790+
assert_eq!(mode & mask, 0, "unwanted permissions are present - {attr}");
57955791
at.write(FIFO, "done");
57965792
child.wait().unwrap().succeeded();
57975793
}

0 commit comments

Comments
 (0)