1
0
mirror of https://github.com/actix/actix-extras.git synced 2025-06-27 10:39:03 +02:00

clippy warnings

This commit is contained in:
Nikolay Kim
2019-12-08 00:46:51 +06:00
parent 8df33f7a81
commit 6c9f9fff73
73 changed files with 222 additions and 207 deletions

View File

@ -154,7 +154,7 @@ where
{
type Output = Result<AppInitService<T::Service, B>, ()>;
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();
// async data factories
@ -220,7 +220,7 @@ where
type Error = T::Error;
type Future = T::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>> {
self.service.poll_ready(cx)
}
@ -310,7 +310,7 @@ enum CreateAppRoutingItem {
impl Future for AppRoutingFactoryResponse {
type Output = Result<AppRouting, ()>;
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 done = true;
if let Some(ref mut fut) = self.default_fut {
@ -381,7 +381,7 @@ impl Service for AppRouting {
type Error = Error;
type Future = BoxResponse;
fn poll_ready(&mut self, _: &mut Context) -> Poll<Result<(), Self::Error>> {
fn poll_ready(&mut self, _: &mut Context<'_>) -> Poll<Result<(), Self::Error>> {
if self.ready.is_none() {
Poll::Ready(Ok(()))
} else {

View File

@ -220,7 +220,7 @@ macro_rules! tuple_from_req ({$fut_type:ident, $(($n:tt, $T:ident)),+} => {
{
type Output = Result<($($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> {
let this = self.project();
let mut ready = true;

View File

@ -85,7 +85,7 @@ where
type Error = Infallible;
type Future = HandlerServiceResponse<R, O>;
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(()))
}
@ -119,7 +119,7 @@ where
{
type Output = Result<ServiceResponse, Infallible>;
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 this = self.as_mut().project();
if let Some(fut) = this.fut2.as_pin_mut() {
@ -203,7 +203,7 @@ where
type Error = (Error, ServiceRequest);
type Future = ExtractResponse<T, S>;
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(()))
}
@ -240,7 +240,7 @@ where
{
type Output = Result<ServiceResponse, (Error, ServiceRequest)>;
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 this = self.as_mut().project();
if let Some(fut) = this.fut_s.as_pin_mut() {

View File

@ -1,4 +1,5 @@
#![allow(clippy::borrow_interior_mutable_const)]
#![deny(rust_2018_idioms, warnings)]
#![allow(clippy::type_complexity, clippy::borrow_interior_mutable_const)]
//! Actix web is a small, pragmatic, and extremely fast web framework
//! for Rust.
//!

View File

@ -106,7 +106,7 @@ where
type Error = Error;
type Future = CompressResponse<S, B>;
fn poll_ready(&mut self, cx: &mut Context) -> Poll<Result<(), Self::Error>> {
fn poll_ready(&mut self, cx: &mut Context<'_>) -> Poll<Result<(), Self::Error>> {
self.service.poll_ready(cx)
}
@ -150,7 +150,7 @@ where
{
type Output = Result<ServiceResponse<Encoder<B>>, 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> {
let this = self.project();
match futures::ready!(this.fut.poll(cx)) {

View File

@ -76,7 +76,7 @@ where
type Error = E::Error;
type Future = Either<E::Future, D::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>> {
use ConditionMiddleware::*;
match self {
Enable(service) => service.poll_ready(cx),

View File

@ -124,7 +124,7 @@ where
type Error = Error;
type Future = LocalBoxFuture<'static, Result<Self::Response, Self::Error>>;
fn poll_ready(&mut self, cx: &mut Context) -> Poll<Result<(), Self::Error>> {
fn poll_ready(&mut self, cx: &mut Context<'_>) -> Poll<Result<(), Self::Error>> {
self.service.poll_ready(cx)
}

View File

@ -119,7 +119,7 @@ where
type Error = Error;
type Future = LocalBoxFuture<'static, Result<Self::Response, Self::Error>>;
fn poll_ready(&mut self, cx: &mut Context) -> Poll<Result<(), Self::Error>> {
fn poll_ready(&mut self, cx: &mut Context<'_>) -> Poll<Result<(), Self::Error>> {
self.service.poll_ready(cx)
}

View File

@ -154,7 +154,7 @@ where
type Error = Error;
type Future = LoggerResponse<S, B>;
fn poll_ready(&mut self, cx: &mut Context) -> Poll<Result<(), Self::Error>> {
fn poll_ready(&mut self, cx: &mut Context<'_>) -> Poll<Result<(), Self::Error>> {
self.service.poll_ready(cx)
}
@ -204,7 +204,7 @@ where
{
type Output = Result<ServiceResponse<StreamLog<B>>, 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> {
let this = self.project();
let res = match futures::ready!(this.fut.poll(cx)) {
@ -248,7 +248,7 @@ pub struct StreamLog<B> {
impl<B> Drop for StreamLog<B> {
fn drop(&mut self) {
if let Some(ref format) = self.format {
let render = |fmt: &mut Formatter| {
let render = |fmt: &mut Formatter<'_>| {
for unit in &format.0 {
unit.render(fmt, self.size, self.time)?;
}
@ -264,7 +264,7 @@ impl<B: MessageBody> MessageBody for StreamLog<B> {
self.body.size()
}
fn poll_next(&mut self, cx: &mut Context) -> Poll<Option<Result<Bytes, Error>>> {
fn poll_next(&mut self, cx: &mut Context<'_>) -> Poll<Option<Result<Bytes, Error>>> {
match self.body.poll_next(cx) {
Poll::Ready(Some(Ok(chunk))) => {
self.size += chunk.len();
@ -364,7 +364,7 @@ pub enum FormatText {
impl FormatText {
fn render(
&self,
fmt: &mut Formatter,
fmt: &mut Formatter<'_>,
size: usize,
entry_time: time::Tm,
) -> Result<(), fmt::Error> {
@ -464,11 +464,11 @@ impl FormatText {
}
pub(crate) struct FormatDisplay<'a>(
&'a dyn Fn(&mut Formatter) -> Result<(), fmt::Error>,
&'a dyn Fn(&mut Formatter<'_>) -> Result<(), fmt::Error>,
);
impl<'a> fmt::Display for FormatDisplay<'a> {
fn fmt(&self, fmt: &mut Formatter) -> Result<(), fmt::Error> {
fn fmt(&self, fmt: &mut Formatter<'_>) -> Result<(), fmt::Error> {
(self.0)(fmt)
}
}
@ -523,7 +523,7 @@ mod tests {
unit.render_response(&resp);
}
let render = |fmt: &mut Formatter| {
let render = |fmt: &mut Formatter<'_>| {
for unit in &format.0 {
unit.render(fmt, 1024, now)?;
}
@ -555,7 +555,7 @@ mod tests {
}
let entry_time = time::now();
let render = |fmt: &mut Formatter| {
let render = |fmt: &mut Formatter<'_>| {
for unit in &format.0 {
unit.render(fmt, 1024, entry_time)?;
}
@ -582,7 +582,7 @@ mod tests {
unit.render_response(&resp);
}
let render = |fmt: &mut Formatter| {
let render = |fmt: &mut Formatter<'_>| {
for unit in &format.0 {
unit.render(fmt, 1024, now)?;
}

View File

@ -68,7 +68,7 @@ where
type Error = Error;
type Future = S::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>> {
self.service.poll_ready(cx)
}
@ -88,7 +88,6 @@ where
Bytes::copy_from_slice(path.as_bytes())
};
parts.path_and_query = Some(PathAndQuery::from_maybe_shared(path).unwrap());
drop(head);
let uri = Uri::from_parts(parts).unwrap();
req.match_info_mut().get_mut().update(&uri);

View File

@ -125,13 +125,13 @@ impl HttpRequest {
/// Request extensions
#[inline]
pub fn extensions(&self) -> Ref<Extensions> {
pub fn extensions(&self) -> Ref<'_, Extensions> {
self.head().extensions()
}
/// Mutable reference to a the request's extensions
#[inline]
pub fn extensions_mut(&self) -> RefMut<Extensions> {
pub fn extensions_mut(&self) -> RefMut<'_, Extensions> {
self.head().extensions_mut()
}
@ -197,7 +197,7 @@ impl HttpRequest {
/// This method panics if request's extensions container is already
/// borrowed.
#[inline]
pub fn connection_info(&self) -> Ref<ConnectionInfo> {
pub fn connection_info(&self) -> Ref<'_, ConnectionInfo> {
ConnectionInfo::get(self.head(), &*self.app_config())
}
@ -239,13 +239,13 @@ impl HttpMessage for HttpRequest {
/// Request extensions
#[inline]
fn extensions(&self) -> Ref<Extensions> {
fn extensions(&self) -> Ref<'_, Extensions> {
self.0.head.extensions()
}
/// Mutable reference to a the request's extensions
#[inline]
fn extensions_mut(&self) -> RefMut<Extensions> {
fn extensions_mut(&self) -> RefMut<'_, Extensions> {
self.0.head.extensions_mut()
}
@ -299,7 +299,7 @@ impl FromRequest for HttpRequest {
}
impl fmt::Debug for HttpRequest {
fn fmt(&self, f: &mut fmt::Formatter) -> fmt::Result {
fn fmt(&self, f: &mut fmt::Formatter<'_>) -> fmt::Result {
writeln!(
f,
"\nHttpRequest {:?} {}:{}",

View File

@ -470,7 +470,7 @@ pub struct CreateResourceService {
impl Future for CreateResourceService {
type Output = Result<ResourceService, ()>;
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 done = true;
if let Some(ref mut fut) = self.default_fut {
@ -530,7 +530,7 @@ impl Service for ResourceService {
LocalBoxFuture<'static, Result<ServiceResponse, Error>>,
>;
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

@ -313,7 +313,7 @@ pub struct CustomResponderFut<T: Responder> {
impl<T: Responder> Future for CustomResponderFut<T> {
type Output = Result<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> {
let this = self.project();
let mut res = match ready!(this.fut.poll(cx)) {
@ -397,7 +397,7 @@ where
type Output = Result<Response, Error>;
#[project]
fn poll(self: Pin<&mut Self>, cx: &mut Context) -> Poll<Self::Output> {
fn poll(self: Pin<&mut Self>, cx: &mut Context<'_>) -> Poll<Self::Output> {
#[project]
match self.project() {
EitherResponder::A(fut) => {
@ -446,7 +446,7 @@ where
{
type Output = Result<Response, 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> {
Poll::Ready(ready!(self.project().fut.poll(cx)).map_err(|e| e.into()))
}
}

View File

@ -92,7 +92,7 @@ pub struct CreateRouteService {
impl Future for CreateRouteService {
type Output = Result<RouteService, ()>;
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)? {
@ -127,7 +127,7 @@ impl Service for RouteService {
type Error = Error;
type Future = LocalBoxFuture<'static, Result<Self::Response, Self::Error>>;
fn poll_ready(&mut self, cx: &mut Context) -> Poll<Result<(), Self::Error>> {
fn poll_ready(&mut self, cx: &mut Context<'_>) -> Poll<Result<(), Self::Error>> {
self.service.poll_ready(cx)
}
@ -313,7 +313,7 @@ where
type Error = Error;
type Future = LocalBoxFuture<'static, Result<Self::Response, Self::Error>>;
fn poll_ready(&mut self, cx: &mut Context) -> Poll<Result<(), Self::Error>> {
fn poll_ready(&mut self, cx: &mut Context<'_>) -> Poll<Result<(), Self::Error>> {
self.service.poll_ready(cx).map_err(|(e, _)| e)
}

View File

@ -534,7 +534,7 @@ enum CreateScopeServiceItem {
impl Future for ScopeFactoryResponse {
type Output = Result<ScopeService, ()>;
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 done = true;
if let Some(ref mut fut) = self.default_fut {
@ -606,7 +606,7 @@ impl Service for ScopeService {
type Error = Error;
type Future = Either<BoxedResponse, Ready<Result<Self::Response, Self::Error>>>;
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

@ -5,7 +5,6 @@ use std::{fmt, io, net};
use actix_http::{
body::MessageBody, Error, HttpService, KeepAlive, Protocol, Request, Response,
};
use actix_rt::System;
use actix_server::{Server, ServerBuilder};
use actix_service::{pipeline_factory, IntoServiceFactory, Service, ServiceFactory};
use futures::future::ok;

View File

@ -181,7 +181,7 @@ impl ServiceRequest {
/// Get *ConnectionInfo* for the current request.
#[inline]
pub fn connection_info(&self) -> Ref<ConnectionInfo> {
pub fn connection_info(&self) -> Ref<'_, ConnectionInfo> {
ConnectionInfo::get(self.head(), &*self.app_config())
}
@ -253,13 +253,13 @@ impl HttpMessage for ServiceRequest {
/// Request extensions
#[inline]
fn extensions(&self) -> Ref<Extensions> {
fn extensions(&self) -> Ref<'_, Extensions> {
self.0.extensions()
}
/// Mutable reference to a the request's extensions
#[inline]
fn extensions_mut(&self) -> RefMut<Extensions> {
fn extensions_mut(&self) -> RefMut<'_, Extensions> {
self.0.extensions_mut()
}
@ -270,7 +270,7 @@ impl HttpMessage for ServiceRequest {
}
impl fmt::Debug for ServiceRequest {
fn fmt(&self, f: &mut fmt::Formatter) -> fmt::Result {
fn fmt(&self, f: &mut fmt::Formatter<'_>) -> fmt::Result {
writeln!(
f,
"\nServiceRequest {:?} {}:{}",
@ -404,7 +404,7 @@ impl<B> Into<Response<B>> for ServiceResponse<B> {
}
impl<B: MessageBody> fmt::Debug for ServiceResponse<B> {
fn fmt(&self, f: &mut fmt::Formatter) -> fmt::Result {
fn fmt(&self, f: &mut fmt::Formatter<'_>) -> fmt::Result {
let res = writeln!(
f,
"\nServiceResponse {:?} {}{}",

View File

@ -388,7 +388,7 @@ impl TestRequest {
}
/// Set cookie for this request
pub fn cookie(mut self, cookie: Cookie) -> Self {
pub fn cookie(mut self, cookie: Cookie<'_>) -> Self {
self.req.cookie(cookie);
self
}

View File

@ -141,13 +141,13 @@ where
}
impl<T: fmt::Debug> fmt::Debug for Form<T> {
fn fmt(&self, f: &mut fmt::Formatter) -> fmt::Result {
fn fmt(&self, f: &mut fmt::Formatter<'_>) -> fmt::Result {
self.0.fmt(f)
}
}
impl<T: fmt::Display> fmt::Display for Form<T> {
fn fmt(&self, f: &mut fmt::Formatter) -> fmt::Result {
fn fmt(&self, f: &mut fmt::Formatter<'_>) -> fmt::Result {
self.0.fmt(f)
}
}
@ -308,7 +308,7 @@ where
{
type Output = Result<U, UrlencodedError>;
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> {
if let Some(ref mut fut) = self.fut {
return Pin::new(fut).poll(cx);
}

View File

@ -106,7 +106,7 @@ impl<T> fmt::Debug for Json<T>
where
T: fmt::Debug,
{
fn fmt(&self, f: &mut fmt::Formatter) -> fmt::Result {
fn fmt(&self, f: &mut fmt::Formatter<'_>) -> fmt::Result {
write!(f, "Json: {:?}", self.0)
}
}
@ -115,7 +115,7 @@ impl<T> fmt::Display for Json<T>
where
T: fmt::Display,
{
fn fmt(&self, f: &mut fmt::Formatter) -> fmt::Result {
fn fmt(&self, f: &mut fmt::Formatter<'_>) -> fmt::Result {
fmt::Display::fmt(&self.0, f)
}
}
@ -356,7 +356,7 @@ where
{
type Output = Result<U, JsonPayloadError>;
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> {
if let Some(ref mut fut) = self.fut {
return Pin::new(fut).poll(cx);
}

View File

@ -97,13 +97,13 @@ impl<T> From<T> for Path<T> {
}
impl<T: fmt::Debug> fmt::Debug for Path<T> {
fn fmt(&self, f: &mut fmt::Formatter) -> fmt::Result {
fn fmt(&self, f: &mut fmt::Formatter<'_>) -> fmt::Result {
self.inner.fmt(f)
}
}
impl<T: fmt::Display> fmt::Display for Path<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

@ -59,7 +59,7 @@ impl Stream for Payload {
#[inline]
fn poll_next(
mut self: Pin<&mut Self>,
cx: &mut Context,
cx: &mut Context<'_>,
) -> Poll<Option<Self::Item>> {
Pin::new(&mut self.0).poll_next(cx)
}
@ -351,7 +351,7 @@ impl HttpMessageBody {
impl Future for HttpMessageBody {
type Output = Result<Bytes, PayloadError>;
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> {
if let Some(ref mut fut) = self.fut {
return Pin::new(fut).poll(cx);
}

View File

@ -84,13 +84,13 @@ impl<T> ops::DerefMut for Query<T> {
}
impl<T: fmt::Debug> fmt::Debug for Query<T> {
fn fmt(&self, f: &mut fmt::Formatter) -> fmt::Result {
fn fmt(&self, f: &mut fmt::Formatter<'_>) -> fmt::Result {
self.0.fmt(f)
}
}
impl<T: fmt::Display> fmt::Display for Query<T> {
fn fmt(&self, f: &mut fmt::Formatter) -> fmt::Result {
fn fmt(&self, f: &mut fmt::Formatter<'_>) -> fmt::Result {
self.0.fmt(f)
}
}

View File

@ -68,7 +68,10 @@ where
{
type Item = Result<String, ReadlinesError>;
fn poll_next(self: Pin<&mut Self>, cx: &mut Context) -> Poll<Option<Self::Item>> {
fn poll_next(
self: Pin<&mut Self>,
cx: &mut Context<'_>,
) -> Poll<Option<Self::Item>> {
let this = self.get_mut();
if let Some(err) = this.err.take() {