From 4edf53e4bb77aca8ddc6a0f0a9e87732383845c9 Mon Sep 17 00:00:00 2001 From: Vincent Thomas Date: Tue, 26 May 2026 08:48:29 +0000 Subject: [PATCH] chore: reduce clippy allowances --- lio/src/api/ops.rs | 4 +- lio/src/fs.rs | 88 +++++++++++++++----------------- lio/tests/net_socket_datagram.rs | 14 ++--- lio/tests/net_udp.rs | 14 ++--- 4 files changed, 55 insertions(+), 65 deletions(-) diff --git a/lio/src/api/ops.rs b/lio/src/api/ops.rs index 1cd6cd7..3007558 100644 --- a/lio/src/api/ops.rs +++ b/lio/src/api/ops.rs @@ -1,5 +1,3 @@ -#![allow(clippy::unnecessary_lazy_evaluations)] - //! I/O operation definitions. //! //! This module contains all the typed operation structs that implement `TypedOp`. @@ -1073,7 +1071,7 @@ impl OpModel for RecvFrom { let addr = result .as_ref() .ok() - .and_then(|_| self.core.from.as_ref()) + .and(self.core.from.as_ref()) .and_then(|from| socket_addr_from_buf(from).ok()); OpResult::Done((result, buf, addr)) } diff --git a/lio/src/fs.rs b/lio/src/fs.rs index 05baddd..99c396c 100644 --- a/lio/src/fs.rs +++ b/lio/src/fs.rs @@ -1,5 +1,3 @@ -#![allow(clippy::never_loop)] - //! Filesystem resource types. use std::{ @@ -514,57 +512,51 @@ impl RemoveDirAll { } fn advance(&mut self) -> OpResult> { - loop { - let Some(frame) = self.stack.last_mut() else { - self.state = RemoveDirAllState::Done; - return OpResult::Done(Ok(())); - }; - - if let Some(entry) = frame.entries.pop() { - match entry.file_type { - Some(FileType::Directory) => { - self.state = RemoveDirAllState::Opening { - op: ops::OpenAt::new( - frame.fd.clone(), - entry.name.clone(), - libc::O_RDONLY | libc::O_DIRECTORY, - 0, - ), - parent: frame.fd.clone(), - name: entry.name, - }; - } - Some(_) => { - self.state = RemoveDirAllState::RemovingEntry { - op: ops::UnlinkAt::new(frame.fd.clone(), entry.name, 0), - }; - } - None => { - self.state = RemoveDirAllState::Stating { - op: ops::Stat::new_at( - frame.fd.clone(), - entry.name.clone(), - false, - ), - parent: frame.fd.clone(), - name: entry.name, - }; - } - } - return OpResult::Again; - } + let Some(frame) = self.stack.last_mut() else { + self.state = RemoveDirAllState::Done; + return OpResult::Done(Ok(())); + }; - if !frame.eof { - self.state = RemoveDirAllState::Reading { op: frame.next_read() }; - return OpResult::Again; + if let Some(entry) = frame.entries.pop() { + match entry.file_type { + Some(FileType::Directory) => { + self.state = RemoveDirAllState::Opening { + op: ops::OpenAt::new( + frame.fd.clone(), + entry.name.clone(), + libc::O_RDONLY | libc::O_DIRECTORY, + 0, + ), + parent: frame.fd.clone(), + name: entry.name, + }; + } + Some(_) => { + self.state = RemoveDirAllState::RemovingEntry { + op: ops::UnlinkAt::new(frame.fd.clone(), entry.name, 0), + }; + } + None => { + self.state = RemoveDirAllState::Stating { + op: ops::Stat::new_at(frame.fd.clone(), entry.name.clone(), false), + parent: frame.fd.clone(), + name: entry.name, + }; + } } + return OpResult::Again; + } - let frame = self.stack.pop().expect("remove_dir_all stack missing frame"); - self.state = RemoveDirAllState::RemovingDir { - op: ops::UnlinkAt::new(frame.parent, frame.name, libc::AT_REMOVEDIR), - }; + if !frame.eof { + self.state = RemoveDirAllState::Reading { op: frame.next_read() }; return OpResult::Again; } + + let frame = self.stack.pop().expect("remove_dir_all stack missing frame"); + self.state = RemoveDirAllState::RemovingDir { + op: ops::UnlinkAt::new(frame.parent, frame.name, libc::AT_REMOVEDIR), + }; + OpResult::Again } } diff --git a/lio/tests/net_socket_datagram.rs b/lio/tests/net_socket_datagram.rs index 88dac3d..7c80852 100644 --- a/lio/tests/net_socket_datagram.rs +++ b/lio/tests/net_socket_datagram.rs @@ -1,8 +1,11 @@ -#![allow(clippy::type_complexity)] #![cfg(feature = "high")] use std::{cell::RefCell, net::SocketAddr, rc::Rc}; +type DatagramRecv = (std::io::Result, Vec, Option); +type DatagramRecvRx = Receiver; +type DatagramRecvDone = Rc, Option)>>>; + use lio::{ Lio, api::Receiver, @@ -14,15 +17,12 @@ struct ReceiverNode { socket_rx: Option>>, socket: Option, bind_rx: Option>>, - recv_rx: - Option, Vec, Option)>>, - recv_done: Rc, Option)>>>, + recv_rx: Option, + recv_done: DatagramRecvDone, } impl ReceiverNode { - fn new( - recv_done: Rc, Option)>>>, - ) -> Self { + fn new(recv_done: DatagramRecvDone) -> Self { Self { socket_rx: None, socket: None, diff --git a/lio/tests/net_udp.rs b/lio/tests/net_udp.rs index a8c6cb5..8429c63 100644 --- a/lio/tests/net_udp.rs +++ b/lio/tests/net_udp.rs @@ -1,8 +1,11 @@ -#![allow(clippy::type_complexity)] #![cfg(feature = "high")] use std::{cell::RefCell, net::SocketAddr, rc::Rc}; +type DatagramRecv = (std::io::Result, Vec, Option); +type DatagramRecvRx = Receiver; +type DatagramRecvDone = Rc, Option)>>>; + use lio::{ Lio, api::Receiver, @@ -54,15 +57,12 @@ impl ReceiverNode { struct DatagramReceiverNode { socket_rx: Option>>, socket: Option, - recv_rx: - Option, Vec, Option)>>, - recv_done: Rc, Option)>>>, + recv_rx: Option, + recv_done: DatagramRecvDone, } impl DatagramReceiverNode { - fn new( - recv_done: Rc, Option)>>>, - ) -> Self { + fn new(recv_done: DatagramRecvDone) -> Self { Self { socket_rx: None, socket: None, recv_rx: None, recv_done } }