diff --git a/examples/chat.rs b/examples/chat.rs index 1d8c6b04684..0a5c5505b24 100644 --- a/examples/chat.rs +++ b/examples/chat.rs @@ -141,7 +141,9 @@ impl Shared { async fn broadcast(&mut self, sender: SocketAddr, message: &str) { for peer in self.peers.iter_mut() { if *peer.0 != sender { - let _ = peer.1.send(message.into()); + if let Err(e) = peer.1.send(message.into()) { + tracing::error!("Failed to send message to {}: {:?}", peer.0, e); + } } } } diff --git a/tokio-util/src/compat.rs b/tokio-util/src/compat.rs index b71e2b1b0f2..3c5ba0d6d28 100644 --- a/tokio-util/src/compat.rs +++ b/tokio-util/src/compat.rs @@ -232,7 +232,9 @@ impl futures_io::AsyncSeek for Compat { *self.as_mut().project().seek_pos = Some(pos); } let res = ready!(self.as_mut().project().inner.poll_complete(cx)); - *self.as_mut().project().seek_pos = None; + if res.is_ok() { + *self.as_mut().project().seek_pos = None; + } Poll::Ready(res) } } @@ -255,7 +257,9 @@ impl tokio::io::AsyncSeek for Compat { Some(pos) => pos, }; let res = ready!(self.as_mut().project().inner.poll_seek(cx, pos)); - *self.as_mut().project().seek_pos = None; + if res.is_ok() { + *self.as_mut().project().seek_pos = None; + } Poll::Ready(res) } } diff --git a/tokio/src/runtime/time/entry.rs b/tokio/src/runtime/time/entry.rs index 834077caa3d..556c0bd317b 100644 --- a/tokio/src/runtime/time/entry.rs +++ b/tokio/src/runtime/time/entry.rs @@ -500,7 +500,7 @@ impl TimerEntry { *self.inner.get() = Some(TimerShared::new(shard_id)); } } - return inner.as_ref().unwrap(); + inner.as_ref().unwrap() } pub(crate) fn deadline(&self) -> Instant { diff --git a/tokio/src/sync/rwlock.rs b/tokio/src/sync/rwlock.rs index ff02c7971d6..d94b6514306 100644 --- a/tokio/src/sync/rwlock.rs +++ b/tokio/src/sync/rwlock.rs @@ -1094,7 +1094,7 @@ impl From for RwLock { } } -impl Default for RwLock +impl Default for RwLock where T: Default, { diff --git a/tokio/tests/io_split.rs b/tokio/tests/io_split.rs index 9f17c9eb14e..8d4e2403ae9 100644 --- a/tokio/tests/io_split.rs +++ b/tokio/tests/io_split.rs @@ -104,9 +104,7 @@ fn method_delegation() { assert_eq!(1, w.write(&[b'x']).await.unwrap()); assert_eq!( 2, - w.write_vectored(&[io::IoSlice::new(&[b'x'])]) - .await - .unwrap() + w.write_vectored(&[io::IoSlice::new(b"x")]).await.unwrap() ); assert!(w.is_write_vectored()); diff --git a/tokio/tests/tcp_accept.rs b/tokio/tests/tcp_accept.rs index 766304778df..8c2984294aa 100644 --- a/tokio/tests/tcp_accept.rs +++ b/tokio/tests/tcp_accept.rs @@ -54,7 +54,7 @@ struct TrackPolls<'a> { listener: &'a mut TcpListener, } -impl<'a> Stream for TrackPolls<'a> { +impl Stream for TrackPolls<'_> { type Item = io::Result<(TcpStream, SocketAddr)>; fn poll_next(self: Pin<&mut Self>, cx: &mut Context<'_>) -> Poll> {