From 93840507e1528f0940592d7578fa1e0ad49722e2 Mon Sep 17 00:00:00 2001 From: Rob Ede Date: Tue, 18 May 2021 17:04:37 +0100 Subject: [PATCH] clippy --- .cargo/config.toml | 2 +- actix-http/src/body/body_stream.rs | 16 +++++++--------- src/error/internal.rs | 2 +- src/types/json.rs | 2 +- src/types/path.rs | 7 ++----- src/types/query.rs | 2 +- 6 files changed, 13 insertions(+), 18 deletions(-) diff --git a/.cargo/config.toml b/.cargo/config.toml index 5db820c37..e4d987dc9 100644 --- a/.cargo/config.toml +++ b/.cargo/config.toml @@ -1,6 +1,6 @@ [alias] chk = "hack check --workspace --all-features --tests --examples" -lint = "hack --clean-per-run clippy --workspace --tests --examples" +lint = "clippy --workspace --tests --examples" ci-min = "hack check --workspace --no-default-features" ci-min-test = "hack check --workspace --no-default-features --tests --examples" ci-default = "hack check --workspace" diff --git a/actix-http/src/body/body_stream.rs b/actix-http/src/body/body_stream.rs index ba32e56e1..f726f4475 100644 --- a/actix-http/src/body/body_stream.rs +++ b/actix-http/src/body/body_stream.rs @@ -74,7 +74,7 @@ mod tests { use actix_utils::future::poll_fn; use derive_more::{Display, Error}; use futures_core::ready; - use futures_util::{stream, FutureExt}; + use futures_util::{stream, FutureExt as _}; use super::*; use crate::body::to_bytes; @@ -134,7 +134,7 @@ mod tests { #[derive(Debug)] enum TimeDelayStream { Start, - Sleep(#[pin] Sleep), + Sleep(Pin>), Done, } @@ -145,24 +145,22 @@ mod tests { mut self: Pin<&mut Self>, cx: &mut Context<'_>, ) -> Poll> { - let this = self.as_mut().project(); - - match this { - TimeDelayStreamProj::Start => { + match self.as_mut().get_mut() { + TimeDelayStream::Start => { let sleep = sleep(Duration::from_millis(1)); - self.set(TimeDelayStream::Sleep(sleep)); + self.as_mut().set(TimeDelayStream::Sleep(Box::pin(sleep))); cx.waker().wake_by_ref(); Poll::Pending } - TimeDelayStreamProj::Sleep(mut delay) => { + TimeDelayStream::Sleep(ref mut delay) => { ready!(delay.poll_unpin(cx)); self.set(TimeDelayStream::Done); cx.waker().wake_by_ref(); Poll::Pending } - TimeDelayStreamProj::Done => Poll::Ready(Some(Err(StreamErr))), + TimeDelayStream::Done => Poll::Ready(Some(Err(StreamErr))), } } } diff --git a/src/error/internal.rs b/src/error/internal.rs index 23b7dc31e..2ea7290a1 100644 --- a/src/error/internal.rs +++ b/src/error/internal.rs @@ -88,7 +88,7 @@ where header::CONTENT_TYPE, header::HeaderValue::from_static("text/plain; charset=utf-8"), ); - res.set_body(Body::from(buf.into_inner())).into() + res.set_body(Body::from(buf.into_inner())) } InternalErrorType::Response(ref resp) => { diff --git a/src/types/json.rs b/src/types/json.rs index 5762c6428..16167e729 100644 --- a/src/types/json.rs +++ b/src/types/json.rs @@ -487,7 +487,7 @@ mod tests { }; let resp = HttpResponse::BadRequest().body(serde_json::to_string(&msg).unwrap()); - InternalError::from_response(err, resp.into()).into() + InternalError::from_response(err, resp).into() })) .to_http_parts(); diff --git a/src/types/path.rs b/src/types/path.rs index 59a107a7e..c4fcd04fe 100644 --- a/src/types/path.rs +++ b/src/types/path.rs @@ -296,11 +296,8 @@ mod tests { async fn test_custom_err_handler() { let (req, mut pl) = TestRequest::with_uri("/name/user1/") .app_data(PathConfig::default().error_handler(|err, _| { - error::InternalError::from_response( - err, - HttpResponse::Conflict().finish().into(), - ) - .into() + error::InternalError::from_response(err, HttpResponse::Conflict().finish()) + .into() })) .to_http_parts(); diff --git a/src/types/query.rs b/src/types/query.rs index 978d00b5f..613a438d3 100644 --- a/src/types/query.rs +++ b/src/types/query.rs @@ -267,7 +267,7 @@ mod tests { let req = TestRequest::with_uri("/name/user1/") .app_data(QueryConfig::default().error_handler(|e, _| { let resp = HttpResponse::UnprocessableEntity().finish(); - InternalError::from_response(e, resp.into()).into() + InternalError::from_response(e, resp).into() })) .to_srv_request();