From 584426d41450ae498ab9424cb729826ecfd07a72 Mon Sep 17 00:00:00 2001 From: royrustdev Date: Tue, 20 Sep 2022 10:46:56 +0530 Subject: [PATCH] fix clippy warnings #378 --- tarpc/src/client.rs | 18 +++++++++--------- tarpc/src/serde_transport.rs | 2 +- tarpc/src/server.rs | 5 +++-- tarpc/src/server/in_flight_requests.rs | 2 +- tarpc/src/server/limits/channels_per_key.rs | 2 +- tarpc/src/server/testing.rs | 2 +- tarpc/tests/dataservice.rs | 2 +- 7 files changed, 17 insertions(+), 16 deletions(-) diff --git a/tarpc/src/client.rs b/tarpc/src/client.rs index 39a6d2c..ad80629 100644 --- a/tarpc/src/client.rs +++ b/tarpc/src/client.rs @@ -628,7 +628,7 @@ mod tests { #[tokio::test] async fn response_completes_request_future() { let (mut dispatch, mut _channel, mut server_channel) = set_up(); - let cx = &mut Context::from_waker(&noop_waker_ref()); + let cx = &mut Context::from_waker(noop_waker_ref()); let (tx, mut rx) = oneshot::channel(); dispatch @@ -656,7 +656,7 @@ mod tests { request_id: 3, }); // resp's drop() is run, which should send a cancel message. - let cx = &mut Context::from_waker(&noop_waker_ref()); + let cx = &mut Context::from_waker(noop_waker_ref()); assert_eq!(canceled_requests.poll_recv(cx), Poll::Ready(Some(3))); } @@ -679,14 +679,14 @@ mod tests { .await .unwrap(); drop(cancellation); - let cx = &mut Context::from_waker(&noop_waker_ref()); + let cx = &mut Context::from_waker(noop_waker_ref()); assert_eq!(canceled_requests.poll_recv(cx), Poll::Ready(None)); } #[tokio::test] async fn stage_request() { let (mut dispatch, mut channel, _server_channel) = set_up(); - let cx = &mut Context::from_waker(&noop_waker_ref()); + let cx = &mut Context::from_waker(noop_waker_ref()); let (tx, mut rx) = oneshot::channel(); let _resp = send_request(&mut channel, "hi", tx, &mut rx).await; @@ -704,7 +704,7 @@ mod tests { #[tokio::test] async fn stage_request_channel_dropped_doesnt_panic() { let (mut dispatch, mut channel, mut server_channel) = set_up(); - let cx = &mut Context::from_waker(&noop_waker_ref()); + let cx = &mut Context::from_waker(noop_waker_ref()); let (tx, mut rx) = oneshot::channel(); let _ = send_request(&mut channel, "hi", tx, &mut rx).await; @@ -726,7 +726,7 @@ mod tests { #[tokio::test] async fn stage_request_response_future_dropped_is_canceled_before_sending() { let (mut dispatch, mut channel, _server_channel) = set_up(); - let cx = &mut Context::from_waker(&noop_waker_ref()); + let cx = &mut Context::from_waker(noop_waker_ref()); let (tx, mut rx) = oneshot::channel(); let _ = send_request(&mut channel, "hi", tx, &mut rx).await; @@ -742,7 +742,7 @@ mod tests { #[tokio::test] async fn stage_request_response_future_dropped_is_canceled_after_sending() { let (mut dispatch, mut channel, _server_channel) = set_up(); - let cx = &mut Context::from_waker(&noop_waker_ref()); + let cx = &mut Context::from_waker(noop_waker_ref()); let (tx, mut rx) = oneshot::channel(); let req = send_request(&mut channel, "hi", tx, &mut rx).await; @@ -763,7 +763,7 @@ mod tests { #[tokio::test] async fn stage_request_response_closed_skipped() { let (mut dispatch, mut channel, _server_channel) = set_up(); - let cx = &mut Context::from_waker(&noop_waker_ref()); + let cx = &mut Context::from_waker(noop_waker_ref()); let (tx, mut rx) = oneshot::channel(); // Test that a request future that's closed its receiver but not yet canceled its request -- @@ -796,7 +796,7 @@ mod tests { let dispatch = RequestDispatch:: { transport: client_channel.fuse(), - pending_requests: pending_requests, + pending_requests, canceled_requests, in_flight_requests: InFlightRequests::default(), config: Config::default(), diff --git a/tarpc/src/serde_transport.rs b/tarpc/src/serde_transport.rs index aaddc36..07d860a 100644 --- a/tarpc/src/serde_transport.rs +++ b/tarpc/src/serde_transport.rs @@ -291,7 +291,7 @@ mod tests { use tokio_serde::formats::SymmetricalJson; fn ctx() -> Context<'static> { - Context::from_waker(&noop_waker_ref()) + Context::from_waker(noop_waker_ref()) } struct TestIo(Cursor>); diff --git a/tarpc/src/server.rs b/tarpc/src/server.rs index 7cf6a95..aacdd5d 100644 --- a/tarpc/src/server.rs +++ b/tarpc/src/server.rs @@ -837,9 +837,10 @@ mod tests { channel::Channel, ClientMessage>, ) { let (tx, rx) = crate::transport::channel::bounded(capacity); - let mut config = Config::default(); // Add 1 because capacity 0 is not supported (but is supported by transport::channel::bounded). - config.pending_response_buffer = capacity + 1; + let config = Config { + pending_response_buffer: capacity + 1, + }; (Box::pin(BaseChannel::new(config, rx).requests()), tx) } diff --git a/tarpc/src/server/in_flight_requests.rs b/tarpc/src/server/in_flight_requests.rs index 07ed1d6..1f8815f 100644 --- a/tarpc/src/server/in_flight_requests.rs +++ b/tarpc/src/server/in_flight_requests.rs @@ -176,7 +176,7 @@ mod tests { .unwrap(); let mut abortable_future = Box::new(Abortable::new(pending::<()>(), abort_registration)); - assert_eq!(in_flight_requests.cancel_request(0), true); + assert!(in_flight_requests.cancel_request(0)); assert_matches!( abortable_future.poll_unpin(&mut noop_context()), Poll::Ready(Err(_)) diff --git a/tarpc/src/server/limits/channels_per_key.rs b/tarpc/src/server/limits/channels_per_key.rs index 272dd56..0cfa97b 100644 --- a/tarpc/src/server/limits/channels_per_key.rs +++ b/tarpc/src/server/limits/channels_per_key.rs @@ -282,7 +282,7 @@ where fn ctx() -> Context<'static> { use futures::task::*; - Context::from_waker(&noop_waker_ref()) + Context::from_waker(noop_waker_ref()) } #[test] diff --git a/tarpc/src/server/testing.rs b/tarpc/src/server/testing.rs index 1c683da..15e187b 100644 --- a/tarpc/src/server/testing.rs +++ b/tarpc/src/server/testing.rs @@ -134,5 +134,5 @@ impl PollExt for Poll> { } pub fn cx() -> Context<'static> { - Context::from_waker(&noop_waker_ref()) + Context::from_waker(noop_waker_ref()) } diff --git a/tarpc/tests/dataservice.rs b/tarpc/tests/dataservice.rs index 9a3c926..365594b 100644 --- a/tarpc/tests/dataservice.rs +++ b/tarpc/tests/dataservice.rs @@ -7,7 +7,7 @@ use tarpc::{ use tokio_serde::formats::Json; #[tarpc::derive_serde] -#[derive(Debug, PartialEq)] +#[derive(Debug, PartialEq, Eq)] pub enum TestData { Black, White,