From d7a32af5340cac61bc80eb2a60fb9f4c9c29468d Mon Sep 17 00:00:00 2001 From: Yuri Astrakhan Date: Thu, 5 Feb 2026 16:45:08 -0500 Subject: [PATCH] chore: a few minor lints I ran this locally, using current main version of clippy: ```bash cargo dev lint path/to/coreutils -- --workspace --all-features ``` --- src/uu/cp/src/cp.rs | 2 +- src/uu/fmt/src/parasplit.rs | 6 +----- src/uu/ls/src/ls.rs | 3 +-- src/uucore/src/lib/features/checksum/mod.rs | 5 +---- 4 files changed, 4 insertions(+), 12 deletions(-) diff --git a/src/uu/cp/src/cp.rs b/src/uu/cp/src/cp.rs index 04a3c1c0110..8fb5629fac1 100644 --- a/src/uu/cp/src/cp.rs +++ b/src/uu/cp/src/cp.rs @@ -1113,7 +1113,7 @@ impl Options { }); } } - overriding_order.sort_by(|a, b| a.0.cmp(&b.0)); + overriding_order.sort_by_key(|a| a.0); let mut attributes = Attributes::NONE; diff --git a/src/uu/fmt/src/parasplit.rs b/src/uu/fmt/src/parasplit.rs index 4fff132eb31..d6a50ef5f42 100644 --- a/src/uu/fmt/src/parasplit.rs +++ b/src/uu/fmt/src/parasplit.rs @@ -421,13 +421,9 @@ impl Iterator for ParagraphStream<'_> { let mut in_mail = false; let mut second_done = false; // for when we use crown or tagged mode - loop { + while let Some(Line::FormatLine(fl)) = self.lines.peek() { // peek ahead // need to explicitly force fl out of scope before we can call self.lines.next() - let Some(Line::FormatLine(fl)) = self.lines.peek() else { - break; - }; - if p_lines.is_empty() { // first time through the loop, get things set up // detect mail header diff --git a/src/uu/ls/src/ls.rs b/src/uu/ls/src/ls.rs index 489fa301b97..0ec9beb408b 100644 --- a/src/uu/ls/src/ls.rs +++ b/src/uu/ls/src/ls.rs @@ -3579,8 +3579,7 @@ fn get_security_context<'a>( }; return uucore::smack::get_smack_label_for_path(&target_path) - .map(Cow::Owned) - .unwrap_or(Cow::Borrowed(SUBSTITUTE_STRING)); + .map_or(Cow::Borrowed(SUBSTITUTE_STRING), Cow::Owned); } Cow::Borrowed(SUBSTITUTE_STRING) diff --git a/src/uucore/src/lib/features/checksum/mod.rs b/src/uucore/src/lib/features/checksum/mod.rs index 0c6dc54f3b5..a2fba209c34 100644 --- a/src/uucore/src/lib/features/checksum/mod.rs +++ b/src/uucore/src/lib/features/checksum/mod.rs @@ -543,10 +543,7 @@ pub fn sanitize_sha2_sha3_length_str(algo_kind: AlgoKind, length: &str) -> UResu pub fn unescape_filename(filename: &[u8]) -> (Vec, &'static str) { let mut unescaped = Vec::with_capacity(filename.len()); let mut byte_iter = filename.iter().peekable(); - loop { - let Some(byte) = byte_iter.next() else { - break; - }; + while let Some(byte) = byte_iter.next() { if *byte == b'\\' { match byte_iter.next() { Some(b'\\') => unescaped.push(b'\\'),