Skip to content

Commit

Permalink
📝 remove needless allow
Browse files Browse the repository at this point in the history
  • Loading branch information
Xudong-Huang committed Feb 25, 2025
1 parent ad232f2 commit 993db42
Show file tree
Hide file tree
Showing 19 changed files with 24 additions and 36 deletions.
1 change: 0 additions & 1 deletion src/cancel.rs
Original file line number Diff line number Diff line change
Expand Up @@ -35,7 +35,6 @@ pub trait CancelIo {
type Data;
fn new() -> Self;
// set the io data
#[allow(dead_code)]
fn set(&self, io_data: Self::Data);
// clear the io data
fn clear(&self);
Expand Down
3 changes: 1 addition & 2 deletions src/coroutine_impl.rs
Original file line number Diff line number Diff line change
Expand Up @@ -90,9 +90,8 @@ impl EventSource for Done {
pub type CoroutineImpl = Generator<'static, EventResult, EventSubscriber>;

#[inline]
#[allow(clippy::cast_ptr_alignment)]
fn get_co_local(co: &CoroutineImpl) -> *mut CoroutineLocal {
co.get_local_data() as *mut CoroutineLocal
co.get_local_data().cast()
}

////////////////////////////////////////////////////////////////////////////////
Expand Down
10 changes: 5 additions & 5 deletions src/io/sys/windows/co_io.rs
Original file line number Diff line number Diff line change
Expand Up @@ -64,11 +64,10 @@ impl<T: AsRawHandle> CoIo<T> {
}
}

/// reset internal io data
#[allow(dead_code)]
pub(crate) fn io_reset(&self) {
self.io.reset()
}
// /// reset internal io data
// pub(crate) fn io_reset(&self) {
// self.io.reset()
// }

/// get inner ref
#[inline]
Expand Down Expand Up @@ -177,6 +176,7 @@ mod tests {

impl AsRawHandle for Hd {
fn as_raw_handle(&self) -> RawHandle {
// this is a fake handle, can't run!
0 as _
}
}
Expand Down
1 change: 0 additions & 1 deletion src/io/sys/windows/iocp.rs
Original file line number Diff line number Diff line change
@@ -1,6 +1,5 @@
use std::cell::UnsafeCell;
use std::os::windows::io::AsRawSocket;
#[cfg(feature = "io_timeout")]
use std::time::Duration;
use std::{io, ptr};

Expand Down
6 changes: 3 additions & 3 deletions src/io/sys/windows/miow.rs
Original file line number Diff line number Diff line change
Expand Up @@ -782,9 +782,9 @@ impl SocketAddrBuf {
/// address filled in and return the standard socket address type.
///
/// If an error is encountered then `None` is returned.
#[allow(clippy::wrong_self_convention)]
pub fn to_socket_addr(&self) -> Option<SocketAddr> {
unsafe { ptrs_to_socket_addr(&self.buf as *const _ as *const _, self.len) }
pub fn get_socket_addr(&self) -> Option<SocketAddr> {
let ptr = (&self.buf as *const SOCKADDR_STORAGE).cast();
unsafe { ptrs_to_socket_addr(ptr, self.len) }
}
}

Expand Down
1 change: 1 addition & 0 deletions src/io/sys/windows/mod.rs
Original file line number Diff line number Diff line change
Expand Up @@ -6,6 +6,7 @@ macro_rules! co_try {
let mut co = $co;
crate::yield_now::set_co_para(&mut co, err);
$s.schedule(co);
#[allow(clippy::needless_return)]
return;
}
}
Expand Down
1 change: 0 additions & 1 deletion src/io/sys/windows/net/socket_write.rs
Original file line number Diff line number Diff line change
Expand Up @@ -41,7 +41,6 @@ impl<'a> SocketWrite<'a> {
}

impl EventSource for SocketWrite<'_> {
#[allow(clippy::needless_return)]
fn subscribe(&mut self, co: CoroutineImpl) {
let s = get_scheduler();
#[cfg(feature = "io_timeout")]
Expand Down
2 changes: 1 addition & 1 deletion src/io/sys/windows/net/udp_recv_from.rs
Original file line number Diff line number Diff line change
Expand Up @@ -43,7 +43,7 @@ impl<'a> UdpRecvFrom<'a> {

pub fn done(&mut self) -> io::Result<(usize, SocketAddr)> {
let size = co_io_result(&self.io_data, self.is_coroutine)?;
let addr = self.addr.to_socket_addr().ok_or_else(|| {
let addr = self.addr.get_socket_addr().ok_or_else(|| {
io::Error::new(io::ErrorKind::Other, "could not obtain remote address")
})?;
Ok((size, addr))
Expand Down
1 change: 0 additions & 1 deletion src/io/sys/windows/net/udp_send_to.rs
Original file line number Diff line number Diff line change
Expand Up @@ -47,7 +47,6 @@ impl<'a> UdpSendTo<'a> {
}

impl EventSource for UdpSendTo<'_> {
#[allow(clippy::needless_return)]
fn subscribe(&mut self, co: CoroutineImpl) {
let s = get_scheduler();
#[cfg(feature = "io_timeout")]
Expand Down
1 change: 0 additions & 1 deletion src/io/sys/windows/pipe/pipe_write.rs
Original file line number Diff line number Diff line change
Expand Up @@ -40,7 +40,6 @@ impl<'a> PipeWrite<'a> {
}

impl EventSource for PipeWrite<'_> {
#[allow(clippy::needless_return)]
fn subscribe(&mut self, co: CoroutineImpl) {
let s = get_scheduler();
#[cfg(feature = "io_timeout")]
Expand Down
3 changes: 1 addition & 2 deletions src/local.rs
Original file line number Diff line number Diff line change
Expand Up @@ -46,8 +46,7 @@ impl CoroutineLocal {
#[inline]
pub fn get_co_local_data() -> Option<NonNull<CoroutineLocal>> {
let ptr = get_local_data();
#[allow(clippy::cast_ptr_alignment)]
NonNull::new(ptr as *mut CoroutineLocal)
NonNull::new(ptr.cast())
}

#[inline]
Expand Down
2 changes: 0 additions & 2 deletions src/net/udp.rs
Original file line number Diff line number Diff line change
Expand Up @@ -250,7 +250,6 @@ impl UdpSocket {
self.sys.set_ttl(ttl)
}

#[allow(clippy::trivially_copy_pass_by_ref)]
pub fn join_multicast_v4(&self, multiaddr: &Ipv4Addr, interface: &Ipv4Addr) -> io::Result<()> {
self.sys.join_multicast_v4(multiaddr, interface)
}
Expand All @@ -259,7 +258,6 @@ impl UdpSocket {
self.sys.join_multicast_v6(multiaddr, interface)
}

#[allow(clippy::trivially_copy_pass_by_ref)]
pub fn leave_multicast_v4(&self, multiaddr: &Ipv4Addr, interface: &Ipv4Addr) -> io::Result<()> {
self.sys.leave_multicast_v4(multiaddr, interface)
}
Expand Down
1 change: 0 additions & 1 deletion src/sync/blocking.rs
Original file line number Diff line number Diff line change
Expand Up @@ -13,7 +13,6 @@ pub struct ThreadPark {
cvar: Condvar,
}

#[allow(clippy::mutex_atomic)]
impl ThreadPark {
pub fn new() -> Self {
ThreadPark {
Expand Down
18 changes: 8 additions & 10 deletions src/sync/delay_drop.rs
Original file line number Diff line number Diff line change
Expand Up @@ -20,16 +20,14 @@ impl DelayDrop {
DropGuard(self)
}

#[allow(dead_code)]
#[inline]
pub fn reset(&self) {
// wait the kernel finished
while self.can_drop.load(Ordering::Acquire) == 2 {
yield_now();
}

self.can_drop.store(0, Ordering::Release);
}
// #[inline]
// pub fn reset(&self) {
// // wait the kernel finished
// while self.can_drop.load(Ordering::Acquire) == 2 {
// yield_now();
// }
// self.can_drop.store(0, Ordering::Release);
// }
}

impl Drop for DropGuard<'_> {
Expand Down
1 change: 0 additions & 1 deletion src/sync/mpmc.rs
Original file line number Diff line number Diff line change
Expand Up @@ -294,7 +294,6 @@ impl<T> fmt::Debug for Receiver<T> {
}

#[cfg(test)]
#[allow(clippy::redundant_clone)]
mod tests {
use super::*;
use std::env;
Expand Down
1 change: 0 additions & 1 deletion src/sync/mpsc.rs
Original file line number Diff line number Diff line change
Expand Up @@ -291,7 +291,6 @@ impl<T> fmt::Debug for Receiver<T> {
}

#[cfg(test)]
#[allow(clippy::redundant_clone)]
mod tests {
use super::*;
use std::env;
Expand Down
1 change: 0 additions & 1 deletion src/sync/rwlock.rs
Original file line number Diff line number Diff line change
Expand Up @@ -317,7 +317,6 @@ impl<T: ?Sized> Drop for RwLockWriteGuard<'_, T> {
}

#[cfg(test)]
#[allow(clippy::redundant_clone)]
mod tests {
use crate::sync::mpsc::channel;
use crate::sync::{Condvar, Mutex, RwLock};
Expand Down
1 change: 0 additions & 1 deletion src/sync/spsc.rs
Original file line number Diff line number Diff line change
Expand Up @@ -359,7 +359,6 @@ impl<T> fmt::Debug for Receiver<T> {
}

#[cfg(test)]
#[allow(clippy::redundant_clone)]
mod tests {
use super::*;
use std::env;
Expand Down
5 changes: 4 additions & 1 deletion tests/lib.rs
Original file line number Diff line number Diff line change
Expand Up @@ -216,17 +216,19 @@ fn yield_from_gen() {
}

#[test]
#[allow(unused_assignments)]
fn unpark() {
let mut a = 0;
let mut b = 0;
coroutine::scope(|scope| {
let h = go!(scope, || {
let co = coroutine::current();
println!("child coroutine name:{co:?}");
co.unpark();
a = 5;
b += a;
coroutine::park();
a = 10;
b += a;
coroutine::park();
});

Expand All @@ -239,6 +241,7 @@ fn unpark() {
});

assert_eq!(a, 10);
assert_eq!(b, 15);
}

#[test]
Expand Down

0 comments on commit 993db42

Please sign in to comment.