mirror of https://github.com/fafhrd91/actix-web
clippy
This commit is contained in:
parent
6353fdc581
commit
93840507e1
|
@ -1,6 +1,6 @@
|
||||||
[alias]
|
[alias]
|
||||||
chk = "hack check --workspace --all-features --tests --examples"
|
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 = "hack check --workspace --no-default-features"
|
||||||
ci-min-test = "hack check --workspace --no-default-features --tests --examples"
|
ci-min-test = "hack check --workspace --no-default-features --tests --examples"
|
||||||
ci-default = "hack check --workspace"
|
ci-default = "hack check --workspace"
|
||||||
|
|
|
@ -74,7 +74,7 @@ mod tests {
|
||||||
use actix_utils::future::poll_fn;
|
use actix_utils::future::poll_fn;
|
||||||
use derive_more::{Display, Error};
|
use derive_more::{Display, Error};
|
||||||
use futures_core::ready;
|
use futures_core::ready;
|
||||||
use futures_util::{stream, FutureExt};
|
use futures_util::{stream, FutureExt as _};
|
||||||
|
|
||||||
use super::*;
|
use super::*;
|
||||||
use crate::body::to_bytes;
|
use crate::body::to_bytes;
|
||||||
|
@ -134,7 +134,7 @@ mod tests {
|
||||||
#[derive(Debug)]
|
#[derive(Debug)]
|
||||||
enum TimeDelayStream {
|
enum TimeDelayStream {
|
||||||
Start,
|
Start,
|
||||||
Sleep(#[pin] Sleep),
|
Sleep(Pin<Box<Sleep>>),
|
||||||
Done,
|
Done,
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -145,24 +145,22 @@ mod tests {
|
||||||
mut self: Pin<&mut Self>,
|
mut self: Pin<&mut Self>,
|
||||||
cx: &mut Context<'_>,
|
cx: &mut Context<'_>,
|
||||||
) -> Poll<Option<Self::Item>> {
|
) -> Poll<Option<Self::Item>> {
|
||||||
let this = self.as_mut().project();
|
match self.as_mut().get_mut() {
|
||||||
|
TimeDelayStream::Start => {
|
||||||
match this {
|
|
||||||
TimeDelayStreamProj::Start => {
|
|
||||||
let sleep = sleep(Duration::from_millis(1));
|
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();
|
cx.waker().wake_by_ref();
|
||||||
Poll::Pending
|
Poll::Pending
|
||||||
}
|
}
|
||||||
|
|
||||||
TimeDelayStreamProj::Sleep(mut delay) => {
|
TimeDelayStream::Sleep(ref mut delay) => {
|
||||||
ready!(delay.poll_unpin(cx));
|
ready!(delay.poll_unpin(cx));
|
||||||
self.set(TimeDelayStream::Done);
|
self.set(TimeDelayStream::Done);
|
||||||
cx.waker().wake_by_ref();
|
cx.waker().wake_by_ref();
|
||||||
Poll::Pending
|
Poll::Pending
|
||||||
}
|
}
|
||||||
|
|
||||||
TimeDelayStreamProj::Done => Poll::Ready(Some(Err(StreamErr))),
|
TimeDelayStream::Done => Poll::Ready(Some(Err(StreamErr))),
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
|
@ -88,7 +88,7 @@ where
|
||||||
header::CONTENT_TYPE,
|
header::CONTENT_TYPE,
|
||||||
header::HeaderValue::from_static("text/plain; charset=utf-8"),
|
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) => {
|
InternalErrorType::Response(ref resp) => {
|
||||||
|
|
|
@ -487,7 +487,7 @@ mod tests {
|
||||||
};
|
};
|
||||||
let resp =
|
let resp =
|
||||||
HttpResponse::BadRequest().body(serde_json::to_string(&msg).unwrap());
|
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();
|
.to_http_parts();
|
||||||
|
|
||||||
|
|
|
@ -296,10 +296,7 @@ mod tests {
|
||||||
async fn test_custom_err_handler() {
|
async fn test_custom_err_handler() {
|
||||||
let (req, mut pl) = TestRequest::with_uri("/name/user1/")
|
let (req, mut pl) = TestRequest::with_uri("/name/user1/")
|
||||||
.app_data(PathConfig::default().error_handler(|err, _| {
|
.app_data(PathConfig::default().error_handler(|err, _| {
|
||||||
error::InternalError::from_response(
|
error::InternalError::from_response(err, HttpResponse::Conflict().finish())
|
||||||
err,
|
|
||||||
HttpResponse::Conflict().finish().into(),
|
|
||||||
)
|
|
||||||
.into()
|
.into()
|
||||||
}))
|
}))
|
||||||
.to_http_parts();
|
.to_http_parts();
|
||||||
|
|
|
@ -267,7 +267,7 @@ mod tests {
|
||||||
let req = TestRequest::with_uri("/name/user1/")
|
let req = TestRequest::with_uri("/name/user1/")
|
||||||
.app_data(QueryConfig::default().error_handler(|e, _| {
|
.app_data(QueryConfig::default().error_handler(|e, _| {
|
||||||
let resp = HttpResponse::UnprocessableEntity().finish();
|
let resp = HttpResponse::UnprocessableEntity().finish();
|
||||||
InternalError::from_response(e, resp.into()).into()
|
InternalError::from_response(e, resp).into()
|
||||||
}))
|
}))
|
||||||
.to_srv_request();
|
.to_srv_request();
|
||||||
|
|
||||||
|
|
Loading…
Reference in New Issue