diff --git a/actix-files/src/lib.rs b/actix-files/src/lib.rs index ae0204a7..91c05494 100644 --- a/actix-files/src/lib.rs +++ b/actix-files/src/lib.rs @@ -1,6 +1,8 @@ -#![allow(clippy::borrow_interior_mutable_const, clippy::type_complexity)] - //! Static files support + +#![deny(rust_2018_idioms)] +#![allow(clippy::borrow_interior_mutable_const)] + use std::cell::RefCell; use std::fmt::Write; use std::fs::{DirEntry, File}; @@ -62,6 +64,7 @@ pub struct ChunkedReadFile { size: u64, offset: u64, file: Option, + #[allow(clippy::type_complexity)] fut: Option>>>, counter: u64, @@ -72,7 +75,7 @@ impl Stream for ChunkedReadFile { fn poll_next( mut self: Pin<&mut Self>, - cx: &mut Context, + cx: &mut Context<'_>, ) -> Poll> { if let Some(ref mut fut) = self.fut { return match Pin::new(fut).poll(cx) { @@ -224,7 +227,7 @@ fn directory_listing( )) } -type MimeOverride = dyn Fn(&mime::Name) -> DispositionType; +type MimeOverride = dyn Fn(&mime::Name<'_>) -> DispositionType; /// Static files handling /// @@ -232,12 +235,10 @@ type MimeOverride = dyn Fn(&mime::Name) -> DispositionType; /// /// ```rust /// use actix_web::App; -/// use actix_files as fs; +/// use actix_files::Files; /// -/// fn main() { -/// let app = App::new() -/// .service(fs::Files::new("/static", ".")); -/// } +/// let app = App::new() +/// .service(Files::new("/static", ".")); /// ``` pub struct Files { path: String, @@ -330,7 +331,7 @@ impl Files { /// Specifies mime override callback pub fn mime_override(mut self, f: F) -> Self where - F: Fn(&mime::Name) -> DispositionType + 'static, + F: Fn(&mime::Name<'_>) -> DispositionType + 'static, { self.mime_override = Some(Rc::new(f)); self @@ -469,6 +470,7 @@ pub struct FilesService { } impl FilesService { + #[allow(clippy::type_complexity)] fn handle_err( &mut self, e: io::Error, @@ -490,12 +492,13 @@ impl Service for FilesService { type Request = ServiceRequest; type Response = ServiceResponse; type Error = Error; + #[allow(clippy::type_complexity)] type Future = Either< Ready>, LocalBoxFuture<'static, Result>, >; - fn poll_ready(&mut self, _: &mut Context) -> Poll> { + fn poll_ready(&mut self, _: &mut Context<'_>) -> Poll> { Poll::Ready(Ok(())) } @@ -898,7 +901,7 @@ mod tests { #[actix_rt::test] async fn test_mime_override() { - fn all_attachment(_: &mime::Name) -> DispositionType { + fn all_attachment(_: &mime::Name<'_>) -> DispositionType { DispositionType::Attachment } diff --git a/actix-http/src/body.rs b/actix-http/src/body.rs index 8bea8e6b..c5d831c4 100644 --- a/actix-http/src/body.rs +++ b/actix-http/src/body.rs @@ -714,7 +714,7 @@ mod tests { let body = resp_body.downcast_ref::().unwrap(); assert_eq!(body, "hello cast"); let body = &mut resp_body.downcast_mut::().unwrap(); - body.push_str("!"); + body.push('!'); let body = resp_body.downcast_ref::().unwrap(); assert_eq!(body, "hello cast!"); let not_body = resp_body.downcast_ref::<()>(); diff --git a/actix-http/src/client/pool.rs b/actix-http/src/client/pool.rs index 013a7967..08abc627 100644 --- a/actix-http/src/client/pool.rs +++ b/actix-http/src/client/pool.rs @@ -119,11 +119,11 @@ where match poll_fn(|cx| Poll::Ready(inner.borrow_mut().acquire(&key, cx))).await { Acquire::Acquired(io, created) => { // use existing connection - return Ok(IoConnection::new( + Ok(IoConnection::new( io, created, Some(Acquired(key, Some(inner))), - )); + )) } Acquire::Available => { // open tcp connection diff --git a/actix-http/src/lib.rs b/actix-http/src/lib.rs index dd8f5ee1..b52e8179 100644 --- a/actix-http/src/lib.rs +++ b/actix-http/src/lib.rs @@ -1,5 +1,6 @@ //! Basic http primitives for actix-net framework. -#![warn(rust_2018_idioms, warnings)] + +#![deny(rust_2018_idioms)] #![allow( clippy::type_complexity, clippy::too_many_arguments, diff --git a/actix-http/src/macros.rs b/actix-http/src/macros.rs index e08d62ba..8973aa39 100644 --- a/actix-http/src/macros.rs +++ b/actix-http/src/macros.rs @@ -87,7 +87,7 @@ mod tests { let body = resp_body.downcast_ref::().unwrap(); assert_eq!(body, "hello cast"); let body = &mut resp_body.downcast_mut::().unwrap(); - body.push_str("!"); + body.push('!'); let body = resp_body.downcast_ref::().unwrap(); assert_eq!(body, "hello cast!"); let not_body = resp_body.downcast_ref::<()>(); diff --git a/actix-multipart/src/lib.rs b/actix-multipart/src/lib.rs index b502c63d..46dd0ee9 100644 --- a/actix-multipart/src/lib.rs +++ b/actix-multipart/src/lib.rs @@ -1,5 +1,6 @@ //! Multipart form support for Actix web. +#![deny(rust_2018_idioms)] #![allow(clippy::borrow_interior_mutable_const)] mod error; diff --git a/actix-multipart/src/server.rs b/actix-multipart/src/server.rs index 449c7da2..1507959b 100644 --- a/actix-multipart/src/server.rs +++ b/actix-multipart/src/server.rs @@ -1,4 +1,5 @@ //! Multipart payload support + use std::cell::{Cell, RefCell, RefMut}; use std::convert::TryFrom; use std::marker::PhantomData; @@ -108,7 +109,7 @@ impl Stream for Multipart { fn poll_next( mut self: Pin<&mut Self>, - cx: &mut Context, + cx: &mut Context<'_>, ) -> Poll> { if let Some(err) = self.error.take() { Poll::Ready(Some(Err(err))) @@ -244,7 +245,7 @@ impl InnerMultipart { fn poll( &mut self, safety: &Safety, - cx: &mut Context, + cx: &mut Context<'_>, ) -> Poll>> { if self.state == InnerState::Eof { Poll::Ready(None) @@ -416,7 +417,10 @@ impl Field { impl Stream for Field { type Item = Result; - fn poll_next(self: Pin<&mut Self>, cx: &mut Context) -> Poll> { + fn poll_next( + self: Pin<&mut Self>, + cx: &mut Context<'_>, + ) -> Poll> { if self.safety.current() { let mut inner = self.inner.borrow_mut(); if let Some(mut payload) = @@ -434,7 +438,7 @@ impl Stream for Field { } impl fmt::Debug for Field { - fn fmt(&self, f: &mut fmt::Formatter) -> fmt::Result { + fn fmt(&self, f: &mut fmt::Formatter<'_>) -> fmt::Result { writeln!(f, "\nField: {}", self.ct)?; writeln!(f, " boundary: {}", self.inner.borrow().boundary)?; writeln!(f, " headers:")?; @@ -689,7 +693,7 @@ impl Safety { self.clean.get() } - fn clone(&self, cx: &mut Context) -> Safety { + fn clone(&self, cx: &mut Context<'_>) -> Safety { let payload = Rc::clone(&self.payload); let s = Safety { task: LocalWaker::new(), @@ -734,7 +738,7 @@ impl PayloadBuffer { } } - fn poll_stream(&mut self, cx: &mut Context) -> Result<(), PayloadError> { + fn poll_stream(&mut self, cx: &mut Context<'_>) -> Result<(), PayloadError> { loop { match Pin::new(&mut self.stream).poll_next(cx) { Poll::Ready(Some(Ok(data))) => self.buf.extend_from_slice(&data), @@ -887,7 +891,7 @@ mod tests { fn poll_next( self: Pin<&mut Self>, - cx: &mut Context, + cx: &mut Context<'_>, ) -> Poll> { let this = self.get_mut(); if !this.ready { diff --git a/actix-web-actors/src/lib.rs b/actix-web-actors/src/lib.rs index d6be5eea..0421f05f 100644 --- a/actix-web-actors/src/lib.rs +++ b/actix-web-actors/src/lib.rs @@ -1,5 +1,6 @@ //! Actix actors integration for Actix web framework +#![deny(rust_2018_idioms)] #![allow(clippy::borrow_interior_mutable_const)] mod context; diff --git a/awc/src/lib.rs b/awc/src/lib.rs index 7167dbb9..4850b78f 100644 --- a/awc/src/lib.rs +++ b/awc/src/lib.rs @@ -1,4 +1,4 @@ -#![warn(rust_2018_idioms, warnings)] +#![deny(rust_2018_idioms)] #![allow( clippy::type_complexity, clippy::borrow_interior_mutable_const, diff --git a/awc/src/sender.rs b/awc/src/sender.rs index 5e0f5bee..0bcdf430 100644 --- a/awc/src/sender.rs +++ b/awc/src/sender.rs @@ -193,11 +193,7 @@ impl RequestSender { } }; - SendClientRequest::new( - fut, - response_decompress, - timeout.or_else(|| config.timeout), - ) + SendClientRequest::new(fut, response_decompress, timeout.or(config.timeout)) } pub(crate) fn send_json( diff --git a/src/lib.rs b/src/lib.rs index 3f65e49d..97141599 100644 --- a/src/lib.rs +++ b/src/lib.rs @@ -1,4 +1,4 @@ -#![warn(rust_2018_idioms, warnings)] +#![deny(rust_2018_idioms)] #![allow(clippy::needless_doctest_main, clippy::type_complexity)] //! Actix web is a powerful, pragmatic, and extremely fast web framework for Rust.