From 01c0a6100154c19618d44322852f0ee88e67448e Mon Sep 17 00:00:00 2001 From: David CARLIER Date: Fri, 24 Oct 2025 10:44:11 +0100 Subject: [PATCH] clippy: fix warnings from nightly (#8991) * uu: addressing clippy warning, find_kp_breakpoints modernize while loop. * however here clippy advice do not seem a gain. yes we can vave Box::new but then we have to clone the chunk.. * feedback, remove also too recent clippy annotation --- src/uu/fmt/src/linebreak.rs | 4 +--- src/uu/tail/src/chunks.rs | 10 +++++----- 2 files changed, 6 insertions(+), 8 deletions(-) diff --git a/src/uu/fmt/src/linebreak.rs b/src/uu/fmt/src/linebreak.rs index 3ed816816..653e7c3e0 100644 --- a/src/uu/fmt/src/linebreak.rs +++ b/src/uu/fmt/src/linebreak.rs @@ -244,9 +244,7 @@ fn find_kp_breakpoints<'a, T: Iterator>>( let mut new_linebreaks = vec![]; let mut is_sentence_start = false; let mut least_demerits = 0; - loop { - let Some(w) = iter.next() else { break }; - + while let Some(w) = iter.next() { // if this is the last word, we don't add additional demerits for this break let (is_last_word, is_sentence_end) = match iter.peek() { None => (true, true), diff --git a/src/uu/tail/src/chunks.rs b/src/uu/tail/src/chunks.rs index bf35d6401..b4ef28e4c 100644 --- a/src/uu/tail/src/chunks.rs +++ b/src/uu/tail/src/chunks.rs @@ -291,14 +291,14 @@ impl BytesChunkBuffer { // fill chunks with all bytes from reader and reuse already instantiated chunks if possible while chunk.fill(reader)?.is_some() { self.bytes += chunk.bytes as u64; - self.chunks.push_back(chunk); + self.chunks.push_back(chunk.clone()); let first = &self.chunks[0]; if self.bytes - first.bytes as u64 > self.num_print { chunk = self.chunks.pop_front().unwrap(); self.bytes -= chunk.bytes as u64; } else { - chunk = Box::new(BytesChunk::new()); + *chunk = BytesChunk::new(); } } @@ -333,7 +333,7 @@ impl BytesChunkBuffer { /// Works similar to a [`BytesChunk`] but also stores the number of lines encountered in the current /// buffer. The size of the buffer is limited to a fixed size number of bytes. -#[derive(Debug)] +#[derive(Clone, Debug)] pub struct LinesChunk { /// Work on top of a [`BytesChunk`] chunk: BytesChunk, @@ -567,7 +567,7 @@ impl LinesChunkBuffer { while chunk.fill(reader)?.is_some() { self.lines += chunk.lines as u64; - self.chunks.push_back(chunk); + self.chunks.push_back(chunk.clone()); let first = &self.chunks[0]; if self.lines - first.lines as u64 > self.num_print { @@ -575,7 +575,7 @@ impl LinesChunkBuffer { self.lines -= chunk.lines as u64; } else { - chunk = Box::new(LinesChunk::new(self.delimiter)); + *chunk = LinesChunk::new(self.delimiter); } }