Skip to content

Commit

Permalink
chore: bump clippy version (tokio-rs#5173)
Browse files Browse the repository at this point in the history
  • Loading branch information
Darksonn authored Nov 6, 2022
1 parent f464360 commit fc9518b
Show file tree
Hide file tree
Showing 30 changed files with 66 additions and 67 deletions.
2 changes: 1 addition & 1 deletion .github/workflows/ci.yml
Original file line number Diff line number Diff line change
Expand Up @@ -12,7 +12,7 @@ env:
# Change to specific Rust release to pin
rust_stable: stable
rust_nightly: nightly-2022-11-03
rust_clippy: 1.56.0
rust_clippy: 1.60.0
# When updating this, also update:
# - README.md
# - tokio/README.md
Expand Down
6 changes: 1 addition & 5 deletions tokio-stream/src/stream_ext/collect.rs
Original file line number Diff line number Diff line change
Expand Up @@ -195,11 +195,7 @@ where
} else {
let res = mem::replace(collection, Ok(U::initialize(sealed::Internal, 0, Some(0))));

if let Err(err) = res {
Err(err)
} else {
unreachable!();
}
Err(res.map(drop).unwrap_err())
}
}
}
Expand Down
2 changes: 1 addition & 1 deletion tokio-stream/src/stream_ext/timeout.rs
Original file line number Diff line number Diff line change
Expand Up @@ -24,7 +24,7 @@ pin_project! {
}

/// Error returned by `Timeout`.
#[derive(Debug, PartialEq)]
#[derive(Debug, PartialEq, Eq)]
pub struct Elapsed(());

impl<S: Stream> Timeout<S> {
Expand Down
2 changes: 1 addition & 1 deletion tokio-stream/src/wrappers/broadcast.rs
Original file line number Diff line number Diff line change
Expand Up @@ -18,7 +18,7 @@ pub struct BroadcastStream<T> {
}

/// An error returned from the inner stream of a [`BroadcastStream`].
#[derive(Debug, PartialEq, Clone)]
#[derive(Debug, PartialEq, Eq, Clone)]
pub enum BroadcastStreamRecvError {
/// The receiver lagged too far behind. Attempting to receive again will
/// return the oldest message still retained by the channel.
Expand Down
2 changes: 1 addition & 1 deletion tokio-util/src/time/delay_queue.rs
Original file line number Diff line number Diff line change
Expand Up @@ -275,7 +275,7 @@ impl<T> SlabStorage<T> {
fn remap_key(&self, key: &Key) -> Option<KeyInternal> {
let key_map = &self.key_map;
if self.compact_called {
key_map.get(&*key).copied()
key_map.get(key).copied()
} else {
Some((*key).into())
}
Expand Down
2 changes: 1 addition & 1 deletion tokio-util/tests/context.rs
Original file line number Diff line number Diff line change
Expand Up @@ -21,5 +21,5 @@ fn tokio_context_with_another_runtime() {

// Without the `HandleExt.wrap()` there would be a panic because there is
// no timer running, since it would be referencing runtime r1.
let _ = rt1.block_on(rt2.wrap(async move { sleep(Duration::from_millis(2)).await }));
rt1.block_on(rt2.wrap(async move { sleep(Duration::from_millis(2)).await }));
}
3 changes: 0 additions & 3 deletions tokio-util/tests/sync_cancellation_token.rs
Original file line number Diff line number Diff line change
Expand Up @@ -206,9 +206,6 @@ fn create_child_token_after_parent_was_cancelled() {
parent_fut.as_mut().poll(&mut Context::from_waker(&waker))
);
assert_eq!(wake_counter, 0);

drop(child_fut);
drop(parent_fut);
}

if drop_child_first {
Expand Down
2 changes: 1 addition & 1 deletion tokio/src/io/ready.rs
Original file line number Diff line number Diff line change
Expand Up @@ -12,7 +12,7 @@ const WRITE_CLOSED: usize = 0b0_1000;
///
/// `Ready` tracks which operation an I/O resource is ready to perform.
#[cfg_attr(docsrs, doc(cfg(feature = "net")))]
#[derive(Clone, Copy, PartialEq, PartialOrd)]
#[derive(Clone, Copy, PartialEq, Eq, PartialOrd, Ord)]
pub struct Ready(usize);

impl Ready {
Expand Down
3 changes: 2 additions & 1 deletion tokio/src/lib.rs
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,8 @@
clippy::cognitive_complexity,
clippy::large_enum_variant,
clippy::module_inception,
clippy::needless_doctest_main
clippy::needless_doctest_main,
clippy::declare_interior_mutable_const
)]
#![warn(
missing_debug_implementations,
Expand Down
4 changes: 3 additions & 1 deletion tokio/src/macros/thread_local.rs
Original file line number Diff line number Diff line change
Expand Up @@ -13,7 +13,9 @@ macro_rules! tokio_thread_local {
#[cfg(not(tokio_no_const_thread_local))]
#[cfg(not(all(loom, test)))]
macro_rules! tokio_thread_local {
($($tts:tt)+) => { ::std::thread_local!{ $($tts)+ } }
($($tts:tt)+) => {
::std::thread_local!{ $($tts)+ }
}
}

#[cfg(tokio_no_const_thread_local)]
Expand Down
2 changes: 1 addition & 1 deletion tokio/src/net/addr.rs
Original file line number Diff line number Diff line change
Expand Up @@ -244,7 +244,7 @@ cfg_net! {
type Future = <str as sealed::ToSocketAddrsPriv>::Future;

fn to_socket_addrs(&self, _: sealed::Internal) -> Self::Future {
(&self[..]).to_socket_addrs(sealed::Internal)
self[..].to_socket_addrs(sealed::Internal)
}
}
}
Expand Down
4 changes: 2 additions & 2 deletions tokio/src/net/udp.rs
Original file line number Diff line number Diff line change
Expand Up @@ -925,7 +925,7 @@ impl UdpSocket {

// Safety: We trust `UdpSocket::recv` to have filled up `n` bytes in the
// buffer.
let n = (&*self.io).recv(dst)?;
let n = (*self.io).recv(dst)?;

unsafe {
buf.advance_mut(n);
Expand Down Expand Up @@ -989,7 +989,7 @@ impl UdpSocket {

// Safety: We trust `UdpSocket::recv_from` to have filled up `n` bytes in the
// buffer.
let (n, addr) = (&*self.io).recv_from(dst)?;
let (n, addr) = (*self.io).recv_from(dst)?;

unsafe {
buf.advance_mut(n);
Expand Down
4 changes: 2 additions & 2 deletions tokio/src/net/unix/datagram/socket.rs
Original file line number Diff line number Diff line change
Expand Up @@ -846,7 +846,7 @@ impl UnixDatagram {

// Safety: We trust `UnixDatagram::recv_from` to have filled up `n` bytes in the
// buffer.
let (n, addr) = (&*self.io).recv_from(dst)?;
let (n, addr) = (*self.io).recv_from(dst)?;

unsafe {
buf.advance_mut(n);
Expand Down Expand Up @@ -909,7 +909,7 @@ impl UnixDatagram {

// Safety: We trust `UnixDatagram::recv` to have filled up `n` bytes in the
// buffer.
let n = (&*self.io).recv(dst)?;
let n = (*self.io).recv(dst)?;

unsafe {
buf.advance_mut(n);
Expand Down
4 changes: 2 additions & 2 deletions tokio/src/runtime/io/mod.rs
Original file line number Diff line number Diff line change
Expand Up @@ -165,11 +165,11 @@ impl Driver {
self.resources.compact()
}

let mut events = &mut self.events;
let events = &mut self.events;

// Block waiting for an event to happen, peeling out how many events
// happened.
match self.poll.poll(&mut events, max_wait) {
match self.poll.poll(events, max_wait) {
Ok(_) => {}
Err(ref e) if e.kind() == io::ErrorKind::Interrupted => {}
#[cfg(tokio_wasi)]
Expand Down
2 changes: 1 addition & 1 deletion tokio/src/sync/batch_semaphore.rs
Original file line number Diff line number Diff line change
Expand Up @@ -49,7 +49,7 @@ struct Waitlist {
/// Error returned from the [`Semaphore::try_acquire`] function.
///
/// [`Semaphore::try_acquire`]: crate::sync::Semaphore::try_acquire
#[derive(Debug, PartialEq)]
#[derive(Debug, PartialEq, Eq)]
pub enum TryAcquireError {
/// The semaphore has been [closed] and cannot issue new permits.
///
Expand Down
4 changes: 2 additions & 2 deletions tokio/src/sync/broadcast.rs
Original file line number Diff line number Diff line change
Expand Up @@ -230,7 +230,7 @@ pub mod error {
///
/// [`recv`]: crate::sync::broadcast::Receiver::recv
/// [`Receiver`]: crate::sync::broadcast::Receiver
#[derive(Debug, PartialEq, Clone)]
#[derive(Debug, PartialEq, Eq, Clone)]
pub enum RecvError {
/// There are no more active senders implying no further messages will ever
/// be sent.
Expand Down Expand Up @@ -258,7 +258,7 @@ pub mod error {
///
/// [`try_recv`]: crate::sync::broadcast::Receiver::try_recv
/// [`Receiver`]: crate::sync::broadcast::Receiver
#[derive(Debug, PartialEq, Clone)]
#[derive(Debug, PartialEq, Eq, Clone)]
pub enum TryRecvError {
/// The channel is currently empty. There are still active
/// [`Sender`] handles, so data may yet become available.
Expand Down
4 changes: 2 additions & 2 deletions tokio/src/sync/once_cell.rs
Original file line number Diff line number Diff line change
Expand Up @@ -106,7 +106,7 @@ impl<T> Drop for OnceCell<T> {
if self.initialized_mut() {
unsafe {
self.value
.with_mut(|ptr| ptr::drop_in_place((&mut *ptr).as_mut_ptr()));
.with_mut(|ptr| ptr::drop_in_place((*ptr).as_mut_ptr()));
};
}
}
Expand Down Expand Up @@ -416,7 +416,7 @@ unsafe impl<T: Send> Send for OnceCell<T> {}
/// Errors that can be returned from [`OnceCell::set`].
///
/// [`OnceCell::set`]: crate::sync::OnceCell::set
#[derive(Debug, PartialEq)]
#[derive(Debug, PartialEq, Eq)]
pub enum SetError<T> {
/// The cell was already initialized when [`OnceCell::set`] was called.
///
Expand Down
6 changes: 3 additions & 3 deletions tokio/src/sync/oneshot.rs
Original file line number Diff line number Diff line change
Expand Up @@ -407,21 +407,21 @@ impl Task {
F: FnOnce(&Waker) -> R,
{
self.0.with(|ptr| {
let waker: *const Waker = (&*ptr).as_ptr();
let waker: *const Waker = (*ptr).as_ptr();
f(&*waker)
})
}

unsafe fn drop_task(&self) {
self.0.with_mut(|ptr| {
let ptr: *mut Waker = (&mut *ptr).as_mut_ptr();
let ptr: *mut Waker = (*ptr).as_mut_ptr();
ptr.drop_in_place();
});
}

unsafe fn set_task(&self, cx: &mut Context<'_>) {
self.0.with_mut(|ptr| {
let ptr: *mut Waker = (&mut *ptr).as_mut_ptr();
let ptr: *mut Waker = (*ptr).as_mut_ptr();
ptr.write(cx.waker().clone());
});
}
Expand Down
2 changes: 1 addition & 1 deletion tokio/src/time/error.rs
Original file line number Diff line number Diff line change
Expand Up @@ -44,7 +44,7 @@ impl From<Kind> for Error {
///
/// This error is returned when a timeout expires before the function was able
/// to finish.
#[derive(Debug, PartialEq)]
#[derive(Debug, PartialEq, Eq)]
pub struct Elapsed(());

#[derive(Debug)]
Expand Down
2 changes: 1 addition & 1 deletion tokio/tests/fs_file.rs
Original file line number Diff line number Diff line change
Expand Up @@ -73,7 +73,7 @@ async fn coop() {
let mut buf = [0; 1024];

loop {
file.read(&mut buf).await.unwrap();
let _ = file.read(&mut buf).await.unwrap();
file.seek(std::io::SeekFrom::Start(0)).await.unwrap();
}
});
Expand Down
36 changes: 18 additions & 18 deletions tokio/tests/io_buf_writer.rs
Original file line number Diff line number Diff line change
Expand Up @@ -70,36 +70,36 @@ where
async fn buf_writer() {
let mut writer = BufWriter::with_capacity(2, Vec::new());

writer.write(&[0, 1]).await.unwrap();
assert_eq!(writer.write(&[0, 1]).await.unwrap(), 2);
assert_eq!(writer.buffer(), []);
assert_eq!(*writer.get_ref(), [0, 1]);

writer.write(&[2]).await.unwrap();
assert_eq!(writer.write(&[2]).await.unwrap(), 1);
assert_eq!(writer.buffer(), [2]);
assert_eq!(*writer.get_ref(), [0, 1]);

writer.write(&[3]).await.unwrap();
assert_eq!(writer.write(&[3]).await.unwrap(), 1);
assert_eq!(writer.buffer(), [2, 3]);
assert_eq!(*writer.get_ref(), [0, 1]);

writer.flush().await.unwrap();
assert_eq!(writer.buffer(), []);
assert_eq!(*writer.get_ref(), [0, 1, 2, 3]);

writer.write(&[4]).await.unwrap();
writer.write(&[5]).await.unwrap();
assert_eq!(writer.write(&[4]).await.unwrap(), 1);
assert_eq!(writer.write(&[5]).await.unwrap(), 1);
assert_eq!(writer.buffer(), [4, 5]);
assert_eq!(*writer.get_ref(), [0, 1, 2, 3]);

writer.write(&[6]).await.unwrap();
assert_eq!(writer.write(&[6]).await.unwrap(), 1);
assert_eq!(writer.buffer(), [6]);
assert_eq!(*writer.get_ref(), [0, 1, 2, 3, 4, 5]);

writer.write(&[7, 8]).await.unwrap();
assert_eq!(writer.write(&[7, 8]).await.unwrap(), 2);
assert_eq!(writer.buffer(), []);
assert_eq!(*writer.get_ref(), [0, 1, 2, 3, 4, 5, 6, 7, 8]);

writer.write(&[9, 10, 11]).await.unwrap();
assert_eq!(writer.write(&[9, 10, 11]).await.unwrap(), 3);
assert_eq!(writer.buffer(), []);
assert_eq!(*writer.get_ref(), [0, 1, 2, 3, 4, 5, 6, 7, 8, 9, 10, 11]);

Expand All @@ -111,7 +111,7 @@ async fn buf_writer() {
#[tokio::test]
async fn buf_writer_inner_flushes() {
let mut w = BufWriter::with_capacity(3, Vec::new());
w.write(&[0, 1]).await.unwrap();
assert_eq!(w.write(&[0, 1]).await.unwrap(), 2);
assert_eq!(*w.get_ref(), []);
w.flush().await.unwrap();
let w = w.into_inner();
Expand All @@ -135,36 +135,36 @@ async fn buf_writer_seek() {
async fn maybe_pending_buf_writer() {
let mut writer = BufWriter::with_capacity(2, MaybePending::new(Vec::new()));

writer.write(&[0, 1]).await.unwrap();
assert_eq!(writer.write(&[0, 1]).await.unwrap(), 2);
assert_eq!(writer.buffer(), []);
assert_eq!(&writer.get_ref().inner, &[0, 1]);

writer.write(&[2]).await.unwrap();
assert_eq!(writer.write(&[2]).await.unwrap(), 1);
assert_eq!(writer.buffer(), [2]);
assert_eq!(&writer.get_ref().inner, &[0, 1]);

writer.write(&[3]).await.unwrap();
assert_eq!(writer.write(&[3]).await.unwrap(), 1);
assert_eq!(writer.buffer(), [2, 3]);
assert_eq!(&writer.get_ref().inner, &[0, 1]);

writer.flush().await.unwrap();
assert_eq!(writer.buffer(), []);
assert_eq!(&writer.get_ref().inner, &[0, 1, 2, 3]);

writer.write(&[4]).await.unwrap();
writer.write(&[5]).await.unwrap();
assert_eq!(writer.write(&[4]).await.unwrap(), 1);
assert_eq!(writer.write(&[5]).await.unwrap(), 1);
assert_eq!(writer.buffer(), [4, 5]);
assert_eq!(&writer.get_ref().inner, &[0, 1, 2, 3]);

writer.write(&[6]).await.unwrap();
assert_eq!(writer.write(&[6]).await.unwrap(), 1);
assert_eq!(writer.buffer(), [6]);
assert_eq!(writer.get_ref().inner, &[0, 1, 2, 3, 4, 5]);

writer.write(&[7, 8]).await.unwrap();
assert_eq!(writer.write(&[7, 8]).await.unwrap(), 2);
assert_eq!(writer.buffer(), []);
assert_eq!(writer.get_ref().inner, &[0, 1, 2, 3, 4, 5, 6, 7, 8]);

writer.write(&[9, 10, 11]).await.unwrap();
assert_eq!(writer.write(&[9, 10, 11]).await.unwrap(), 3);
assert_eq!(writer.buffer(), []);
assert_eq!(
writer.get_ref().inner,
Expand All @@ -182,7 +182,7 @@ async fn maybe_pending_buf_writer() {
#[tokio::test]
async fn maybe_pending_buf_writer_inner_flushes() {
let mut w = BufWriter::with_capacity(3, MaybePending::new(Vec::new()));
w.write(&[0, 1]).await.unwrap();
assert_eq!(w.write(&[0, 1]).await.unwrap(), 2);
assert_eq!(&w.get_ref().inner, &[]);
w.flush().await.unwrap();
let w = w.into_inner().inner;
Expand Down
2 changes: 1 addition & 1 deletion tokio/tests/io_mem_stream.rs
Original file line number Diff line number Diff line change
Expand Up @@ -113,7 +113,7 @@ async fn duplex_is_cooperative() {
let buf = [3u8; 4096];
tx.write_all(&buf).await.unwrap();
let mut buf = [0u8; 4096];
rx.read(&mut buf).await.unwrap();
let _ = rx.read(&mut buf).await.unwrap();
}
} => {},
_ = tokio::task::yield_now() => {}
Expand Down
1 change: 1 addition & 0 deletions tokio/tests/macros_test.rs
Original file line number Diff line number Diff line change
Expand Up @@ -50,6 +50,7 @@ pub async fn issue_4175_test() -> std::io::Result<()> {
}

// https://github.com/tokio-rs/tokio/issues/4175
#[allow(clippy::let_unit_value)]
pub mod clippy_semicolon_if_nothing_returned {
#![deny(clippy::semicolon_if_nothing_returned)]

Expand Down
8 changes: 4 additions & 4 deletions tokio/tests/sync_mpsc.rs
Original file line number Diff line number Diff line change
Expand Up @@ -840,16 +840,16 @@ impl Drop for Msg {
async fn test_msgs_dropped_on_rx_drop() {
let (tx, mut rx) = mpsc::channel(3);

let _ = tx.send(Msg {}).await.unwrap();
let _ = tx.send(Msg {}).await.unwrap();
tx.send(Msg {}).await.unwrap();
tx.send(Msg {}).await.unwrap();

// This msg will be pending and should be dropped when `rx` is dropped
let sent_fut = tx.send(Msg {});

let _ = rx.recv().await.unwrap();
let _ = rx.recv().await.unwrap();

let _ = sent_fut.await.unwrap();
sent_fut.await.unwrap();

drop(rx);

Expand Down Expand Up @@ -936,7 +936,7 @@ async fn test_tx_capacity() {
assert_eq!(tx.capacity(), 9);
assert_eq!(tx.max_capacity(), 10);

let _sent = tx.send(()).await.unwrap();
tx.send(()).await.unwrap();
// after send, capacity should drop by one again
assert_eq!(tx.capacity(), 8);
assert_eq!(tx.max_capacity(), 10);
Expand Down
Loading

0 comments on commit fc9518b

Please sign in to comment.