1
0
mirror of https://github.com/fafhrd91/actix-net synced 2025-06-26 19:47:43 +02:00

clippy warnings

This commit is contained in:
Nikolay Kim
2019-12-02 22:30:09 +06:00
parent 9ed35cca7a
commit 9f575418c1
68 changed files with 355 additions and 452 deletions

View File

@ -1,5 +1,9 @@
# Changes
## [1.0.0-alpha.2] - 2019-12-02
* Migrate to `std::future`
## [0.4.7] - 2019-10-14
* Re-register task on every framed transport poll.

View File

@ -1,6 +1,6 @@
[package]
name = "actix-utils"
version = "0.5.0-alpha1"
version = "1.0.0-alpha.2"
authors = ["Nikolay Kim <fafhrd91@gmail.com>"]
description = "Actix utils - various actix net related services"
keywords = ["network", "framework", "async", "futures"]
@ -18,11 +18,11 @@ name = "actix_utils"
path = "src/lib.rs"
[dependencies]
actix-service = "1.0.0-alpha.1"
actix-rt = "1.0.0-alpha.1"
actix-codec = "0.2.0-alpha.1"
actix-service = "1.0.0-alpha.2"
actix-rt = "1.0.0-alpha.2"
actix-codec = "0.2.0-alpha.2"
bytes = "0.4"
either = "1.5.2"
futures = "0.3.1"
pin-project = "0.4.5"
pin-project = "0.4.6"
log = "0.4"

View File

@ -17,7 +17,7 @@ impl<T> Clone for Cell<T> {
}
impl<T: fmt::Debug> fmt::Debug for Cell<T> {
fn fmt(&self, f: &mut fmt::Formatter) -> fmt::Result {
fn fmt(&self, f: &mut fmt::Formatter<'_>) -> fmt::Result {
self.inner.fmt(f)
}
}

View File

@ -33,7 +33,7 @@ impl Counter {
/// Check if counter is not at capacity. If counter at capacity
/// it registers notification for current task.
pub fn available(&self, cx: &mut task::Context) -> bool {
pub fn available(&self, cx: &mut task::Context<'_>) -> bool {
self.0.available(cx)
}
@ -73,7 +73,7 @@ impl CounterInner {
}
}
fn available(&self, cx: &mut task::Context) -> bool {
fn available(&self, cx: &mut task::Context<'_>) -> bool {
if self.count.get() < self.capacity {
true
} else {

View File

@ -34,7 +34,7 @@ where
type Error = A::Error;
type Future = future::Either<A::Future, B::Future>;
fn poll_ready(&mut self, cx: &mut Context) -> Poll<Result<(), Self::Error>> {
fn poll_ready(&mut self, cx: &mut Context<'_>) -> Poll<Result<(), Self::Error>> {
let left = self.left.poll_ready(cx)?;
let right = self.right.poll_ready(cx)?;
@ -131,7 +131,7 @@ where
{
type Output = Result<EitherService<A::Service, B::Service>, A::InitError>;
fn poll(self: Pin<&mut Self>, cx: &mut Context) -> Poll<Self::Output> {
fn poll(self: Pin<&mut Self>, cx: &mut Context<'_>) -> Poll<Self::Output> {
let this = self.project();
if this.left.is_none() {

View File

@ -37,7 +37,7 @@ where
<U as Encoder>::Error: fmt::Debug,
<U as Decoder>::Error: fmt::Debug,
{
fn fmt(&self, fmt: &mut fmt::Formatter) -> fmt::Result {
fn fmt(&self, fmt: &mut fmt::Formatter<'_>) -> fmt::Result {
match *self {
FramedTransportError::Service(ref e) => {
write!(fmt, "FramedTransportError::Service({:?})", e)
@ -58,7 +58,7 @@ where
<U as Encoder>::Error: fmt::Debug,
<U as Decoder>::Error: fmt::Debug,
{
fn fmt(&self, fmt: &mut fmt::Formatter) -> fmt::Result {
fn fmt(&self, fmt: &mut fmt::Formatter<'_>) -> fmt::Result {
match *self {
FramedTransportError::Service(ref e) => write!(fmt, "{}", e),
FramedTransportError::Encoder(ref e) => write!(fmt, "{:?}", e),
@ -177,7 +177,7 @@ where
{
type Output = Result<(), FramedTransportError<S::Error, U>>;
fn poll(self: Pin<&mut Self>, cx: &mut Context) -> Poll<Self::Output> {
fn poll(self: Pin<&mut Self>, cx: &mut Context<'_>) -> Poll<Self::Output> {
self.inner.get_ref().task.register(cx.waker());
let this = self.project();
@ -193,7 +193,7 @@ where
}
fn poll<S, T, U>(
cx: &mut Context,
cx: &mut Context<'_>,
srv: &mut S,
state: &mut TransportState<S, U>,
framed: &mut Framed<T, U>,
@ -248,7 +248,7 @@ where
}
fn poll_read<S, T, U>(
cx: &mut Context,
cx: &mut Context<'_>,
srv: &mut S,
state: &mut TransportState<S, U>,
framed: &mut Framed<T, U>,
@ -300,7 +300,7 @@ where
/// write to framed object
fn poll_write<S, T, U>(
cx: &mut Context,
cx: &mut Context<'_>,
state: &mut TransportState<S, U>,
framed: &mut Framed<T, U>,
rx: &mut Rx<U>,

View File

@ -73,7 +73,7 @@ where
type Error = T::Error;
type Future = InFlightServiceResponse<T>;
fn poll_ready(&mut self, cx: &mut Context) -> Poll<Result<(), Self::Error>> {
fn poll_ready(&mut self, cx: &mut Context<'_>) -> Poll<Result<(), Self::Error>> {
if let Poll::Pending = self.service.poll_ready(cx)? {
Poll::Pending
} else if !self.count.available(cx) {
@ -103,7 +103,7 @@ pub struct InFlightServiceResponse<T: Service> {
impl<T: Service> Future for InFlightServiceResponse<T> {
type Output = Result<T::Response, T::Error>;
fn poll(self: Pin<&mut Self>, cx: &mut Context) -> Poll<Self::Output> {
fn poll(self: Pin<&mut Self>, cx: &mut Context<'_>) -> Poll<Self::Output> {
self.project().fut.poll(cx)
}
}
@ -126,7 +126,7 @@ mod tests {
type Error = ();
type Future = LocalBoxFuture<'static, Result<(), ()>>;
fn poll_ready(&mut self, _: &mut Context) -> Poll<Result<(), Self::Error>> {
fn poll_ready(&mut self, _: &mut Context<'_>) -> Poll<Result<(), Self::Error>> {
Poll::Ready(Ok(()))
}

View File

@ -102,7 +102,7 @@ where
type Error = E;
type Future = Ready<Result<R, E>>;
fn poll_ready(&mut self, cx: &mut Context) -> Poll<Result<(), Self::Error>> {
fn poll_ready(&mut self, cx: &mut Context<'_>) -> Poll<Result<(), Self::Error>> {
match Pin::new(&mut self.delay).poll(cx) {
Poll::Ready(_) => {
let now = self.time.now();

View File

@ -1,4 +1,6 @@
//! Actix utils - various helper services
#![deny(rust_2018_idioms, warnings)]
#![allow(clippy::type_complexity)]
mod cell;
pub mod counter;

View File

@ -72,7 +72,7 @@ impl<T> Clone for Sender<T> {
impl<T> Sink<T> for Sender<T> {
type Error = SendError<T>;
fn poll_ready(self: Pin<&mut Self>, _: &mut Context) -> Poll<Result<(), Self::Error>> {
fn poll_ready(self: Pin<&mut Self>, _: &mut Context<'_>) -> Poll<Result<(), Self::Error>> {
Poll::Ready(Ok(()))
}
@ -80,11 +80,11 @@ impl<T> Sink<T> for Sender<T> {
self.send(item)
}
fn poll_flush(self: Pin<&mut Self>, _: &mut Context) -> Poll<Result<(), SendError<T>>> {
fn poll_flush(self: Pin<&mut Self>, _: &mut Context<'_>) -> Poll<Result<(), SendError<T>>> {
Poll::Ready(Ok(()))
}
fn poll_close(self: Pin<&mut Self>, _: &mut Context) -> Poll<Result<(), Self::Error>> {
fn poll_close(self: Pin<&mut Self>, _: &mut Context<'_>) -> Poll<Result<(), Self::Error>> {
Poll::Ready(Ok(()))
}
}
@ -144,7 +144,7 @@ impl<T> Receiver<T> {
impl<T> Stream for Receiver<T> {
type Item = T;
fn poll_next(mut self: Pin<&mut Self>, cx: &mut Context) -> Poll<Option<Self::Item>> {
fn poll_next(mut self: Pin<&mut Self>, cx: &mut Context<'_>) -> Poll<Option<Self::Item>> {
let me = match self.state {
State::Open(ref mut me) => me,
State::Closed(ref mut items) => return Poll::Ready(items.pop_front()),
@ -177,13 +177,13 @@ impl<T> Drop for Receiver<T> {
pub struct SendError<T>(T);
impl<T> fmt::Debug for SendError<T> {
fn fmt(&self, fmt: &mut fmt::Formatter) -> fmt::Result {
fn fmt(&self, fmt: &mut fmt::Formatter<'_>) -> fmt::Result {
fmt.debug_tuple("SendError").field(&"...").finish()
}
}
impl<T> fmt::Display for SendError<T> {
fn fmt(&self, fmt: &mut fmt::Formatter) -> fmt::Result {
fn fmt(&self, fmt: &mut fmt::Formatter<'_>) -> fmt::Result {
write!(fmt, "send failed because receiver is gone")
}
}

View File

@ -111,7 +111,7 @@ impl<T> Sender<T> {
/// able to receive a message if sent. The current task, however, is
/// scheduled to receive a notification if the corresponding `Receiver` goes
/// away.
pub fn poll_canceled(&mut self, cx: &mut Context) -> Poll<()> {
pub fn poll_canceled(&mut self, cx: &mut Context<'_>) -> Poll<()> {
match self.inner.upgrade() {
Some(inner) => {
inner.borrow_mut().tx_task.register(cx.waker());

View File

@ -33,7 +33,7 @@ impl<E> From<E> for InOrderError<E> {
}
impl<E: fmt::Debug> fmt::Debug for InOrderError<E> {
fn fmt(&self, f: &mut fmt::Formatter) -> fmt::Result {
fn fmt(&self, f: &mut fmt::Formatter<'_>) -> fmt::Result {
match self {
InOrderError::Service(e) => write!(f, "InOrderError::Service({:?})", e),
InOrderError::Disconnected => write!(f, "InOrderError::Disconnected"),
@ -42,7 +42,7 @@ impl<E: fmt::Debug> fmt::Debug for InOrderError<E> {
}
impl<E: fmt::Display> fmt::Display for InOrderError<E> {
fn fmt(&self, f: &mut fmt::Formatter) -> fmt::Result {
fn fmt(&self, f: &mut fmt::Formatter<'_>) -> fmt::Result {
match self {
InOrderError::Service(e) => e.fmt(f),
InOrderError::Disconnected => write!(f, "InOrder service disconnected"),
@ -140,7 +140,7 @@ where
type Error = InOrderError<S::Error>;
type Future = InOrderServiceResponse<S>;
fn poll_ready(&mut self, cx: &mut Context) -> Poll<Result<(), Self::Error>> {
fn poll_ready(&mut self, cx: &mut Context<'_>) -> Poll<Result<(), Self::Error>> {
// poll_ready could be called from different task
self.task.register(cx.waker());
@ -192,7 +192,7 @@ pub struct InOrderServiceResponse<S: Service> {
impl<S: Service> Future for InOrderServiceResponse<S> {
type Output = Result<S::Response, InOrderError<S::Error>>;
fn poll(mut self: Pin<&mut Self>, cx: &mut Context) -> Poll<Self::Output> {
fn poll(mut self: Pin<&mut Self>, cx: &mut Context<'_>) -> Poll<Self::Output> {
match Pin::new(&mut self.rx).poll(cx) {
Poll::Pending => Poll::Pending,
Poll::Ready(Ok(Ok(res))) => Poll::Ready(Ok(res)),
@ -221,7 +221,7 @@ mod tests {
type Error = ();
type Future = LocalBoxFuture<'static, Result<usize, ()>>;
fn poll_ready(&mut self, _: &mut Context) -> Poll<Result<(), Self::Error>> {
fn poll_ready(&mut self, _: &mut Context<'_>) -> Poll<Result<(), Self::Error>> {
Poll::Ready(Ok(()))
}

View File

@ -46,7 +46,7 @@ where
{
type Output = Result<(), T::Error>;
fn poll(mut self: Pin<&mut Self>, cx: &mut Context) -> Poll<Self::Output> {
fn poll(mut self: Pin<&mut Self>, cx: &mut Context<'_>) -> Poll<Self::Output> {
let mut this = self.as_mut().project();
if let Poll::Ready(Some(e)) = Pin::new(&mut this.err_rx).poll_next(cx) {
@ -85,7 +85,7 @@ where
{
type Output = ();
fn poll(self: Pin<&mut Self>, cx: &mut Context) -> Poll<Self::Output> {
fn poll(self: Pin<&mut Self>, cx: &mut Context<'_>) -> Poll<Self::Output> {
let this = self.project();
match this.fut.poll(cx) {

View File

@ -19,6 +19,7 @@ use std::{fmt, rc};
///
/// A single `AtomicWaker` may be reused for any number of calls to `register` or
/// `wake`.
#[derive(Default)]
pub struct LocalWaker {
waker: UnsafeCell<Option<Waker>>,
_t: PhantomData<rc::Rc<()>>,

View File

@ -34,7 +34,7 @@ impl<E> From<E> for TimeoutError<E> {
}
impl<E: fmt::Debug> fmt::Debug for TimeoutError<E> {
fn fmt(&self, f: &mut fmt::Formatter) -> fmt::Result {
fn fmt(&self, f: &mut fmt::Formatter<'_>) -> fmt::Result {
match self {
TimeoutError::Service(e) => write!(f, "TimeoutError::Service({:?})", e),
TimeoutError::Timeout => write!(f, "TimeoutError::Timeout"),
@ -43,7 +43,7 @@ impl<E: fmt::Debug> fmt::Debug for TimeoutError<E> {
}
impl<E: fmt::Display> fmt::Display for TimeoutError<E> {
fn fmt(&self, f: &mut fmt::Formatter) -> fmt::Result {
fn fmt(&self, f: &mut fmt::Formatter<'_>) -> fmt::Result {
match self {
TimeoutError::Service(e) => e.fmt(f),
TimeoutError::Timeout => write!(f, "Service call timeout"),
@ -193,7 +193,7 @@ mod tests {
type Error = ();
type Future = LocalBoxFuture<'static, Result<(), ()>>;
fn poll_ready(&mut self, _: &mut Context) -> Poll<Result<(), Self::Error>> {
fn poll_ready(&mut self, _: &mut Context<'_>) -> Poll<Result<(), Self::Error>> {
Poll::Ready(Ok(()))
}