diff --git a/src/application.rs b/src/application.rs index 407268322..d8a6cbe7b 100644 --- a/src/application.rs +++ b/src/application.rs @@ -135,7 +135,7 @@ where /// instance for each thread, thus application state must be constructed /// multiple times. If you want to share state between different /// threads, a shared object should be used, e.g. `Arc`. Application - /// state does not need to be `Send` and `Sync`. + /// state does not need to be `Send` or `Sync`. pub fn with_state(state: S) -> App { App { parts: Some(ApplicationParts { diff --git a/src/client/writer.rs b/src/client/writer.rs index 45abfb773..e74f22332 100644 --- a/src/client/writer.rs +++ b/src/client/writer.rs @@ -1,4 +1,7 @@ -#![cfg_attr(feature = "cargo-clippy", allow(redundant_field_names))] +#![cfg_attr( + feature = "cargo-clippy", + allow(clippy::redundant_field_names) +)] use std::cell::RefCell; use std::fmt::Write as FmtWrite; diff --git a/src/extensions.rs b/src/extensions.rs index 3e3f24a24..430b87bda 100644 --- a/src/extensions.rs +++ b/src/extensions.rs @@ -31,6 +31,7 @@ impl Hasher for IdHasher { type AnyMap = HashMap, BuildHasherDefault>; +#[derive(Default)] /// A type map of request extensions. pub struct Extensions { map: AnyMap, diff --git a/src/handler.rs b/src/handler.rs index 2b6cc6604..399fd6ba3 100644 --- a/src/handler.rs +++ b/src/handler.rs @@ -530,8 +530,7 @@ where /// } /// /// /// extract path info using serde -/// fn index(data: (State, Path)) -> String { -/// let (state, path) = data; +/// fn index(state: State, path: Path)) -> String { /// format!("{} {}!", state.msg, path.username) /// } /// diff --git a/src/httpresponse.rs b/src/httpresponse.rs index f02570188..59815c58c 100644 --- a/src/httpresponse.rs +++ b/src/httpresponse.rs @@ -694,7 +694,7 @@ impl HttpResponseBuilder { } #[inline] -#[cfg_attr(feature = "cargo-clippy", allow(borrowed_box))] +#[cfg_attr(feature = "cargo-clippy", allow(clippy::borrowed_box))] fn parts<'a>( parts: &'a mut Option>, err: &Option, ) -> Option<&'a mut Box> { diff --git a/src/info.rs b/src/info.rs index aeffc5ba2..5a2f21805 100644 --- a/src/info.rs +++ b/src/info.rs @@ -16,7 +16,10 @@ pub struct ConnectionInfo { impl ConnectionInfo { /// Create *ConnectionInfo* instance for a request. - #[cfg_attr(feature = "cargo-clippy", allow(cyclomatic_complexity))] + #[cfg_attr( + feature = "cargo-clippy", + allow(clippy::cyclomatic_complexity) + )] pub fn update(&mut self, req: &Request) { let mut host = None; let mut scheme = None; diff --git a/src/lib.rs b/src/lib.rs index df3c3817e..1ed408099 100644 --- a/src/lib.rs +++ b/src/lib.rs @@ -80,6 +80,7 @@ #![cfg_attr(actix_nightly, feature( specialization, // for impl ErrorResponse for std::error::Error extern_prelude, + tool_lints, ))] #![warn(missing_docs)] diff --git a/src/middleware/defaultheaders.rs b/src/middleware/defaultheaders.rs index a33fa6a33..d980a2503 100644 --- a/src/middleware/defaultheaders.rs +++ b/src/middleware/defaultheaders.rs @@ -48,7 +48,7 @@ impl DefaultHeaders { /// Set a header. #[inline] - #[cfg_attr(feature = "cargo-clippy", allow(match_wild_err_arm))] + #[cfg_attr(feature = "cargo-clippy", allow(clippy::match_wild_err_arm))] pub fn header(mut self, key: K, value: V) -> Self where HeaderName: HttpTryFrom, diff --git a/src/route.rs b/src/route.rs index e2635aa65..e4a7a9572 100644 --- a/src/route.rs +++ b/src/route.rs @@ -134,8 +134,7 @@ impl Route { /// } /// ``` /// - /// It is possible to use tuples for specifing multiple extractors for one - /// handler function. + /// It is possible to use multiple extractors for one handler function. /// /// ```rust /// # extern crate bytes; @@ -152,9 +151,9 @@ impl Route { /// /// /// extract path info using serde /// fn index( - /// info: (Path, Query>, Json), + /// path: Path, query: Query>, body: Json, /// ) -> Result { - /// Ok(format!("Welcome {}!", info.0.username)) + /// Ok(format!("Welcome {}!", path.username)) /// } /// /// fn main() { diff --git a/src/scope.rs b/src/scope.rs index bd3daf163..43789d427 100644 --- a/src/scope.rs +++ b/src/scope.rs @@ -59,7 +59,10 @@ pub struct Scope { middlewares: Rc>>>, } -#[cfg_attr(feature = "cargo-clippy", allow(new_without_default_derive))] +#[cfg_attr( + feature = "cargo-clippy", + allow(clippy::new_without_default_derive) +)] impl Scope { /// Create a new scope pub fn new(path: &str) -> Scope { diff --git a/src/server/h2writer.rs b/src/server/h2writer.rs index 4bfc1b7c1..0893b5b62 100644 --- a/src/server/h2writer.rs +++ b/src/server/h2writer.rs @@ -1,4 +1,7 @@ -#![cfg_attr(feature = "cargo-clippy", allow(redundant_field_names))] +#![cfg_attr( + feature = "cargo-clippy", + allow(clippy::redundant_field_names) +)] use std::{cmp, io}; diff --git a/src/server/helpers.rs b/src/server/helpers.rs index 9c0b7f40c..e4ccd8aef 100644 --- a/src/server/helpers.rs +++ b/src/server/helpers.rs @@ -78,7 +78,7 @@ pub fn write_content_length(mut n: usize, bytes: &mut BytesMut) { let d1 = n << 1; unsafe { ptr::copy_nonoverlapping( - DEC_DIGITS_LUT.as_ptr().offset(d1 as isize), + DEC_DIGITS_LUT.as_ptr().add(d1), buf.as_mut_ptr().offset(18), 2, ); @@ -94,7 +94,7 @@ pub fn write_content_length(mut n: usize, bytes: &mut BytesMut) { n /= 100; unsafe { ptr::copy_nonoverlapping( - DEC_DIGITS_LUT.as_ptr().offset(d1 as isize), + DEC_DIGITS_LUT.as_ptr().add(d1), buf.as_mut_ptr().offset(19), 2, ) diff --git a/src/server/http.rs b/src/server/http.rs index 5e1d33512..5a7200868 100644 --- a/src/server/http.rs +++ b/src/server/http.rs @@ -329,7 +329,10 @@ where /// Start listening for incoming connections with supplied acceptor. #[doc(hidden)] - #[cfg_attr(feature = "cargo-clippy", allow(needless_pass_by_value))] + #[cfg_attr( + feature = "cargo-clippy", + allow(clippy::needless_pass_by_value) + )] pub fn bind_with(mut self, addr: S, acceptor: A) -> io::Result where S: net::ToSocketAddrs, diff --git a/src/server/output.rs b/src/server/output.rs index 74b083388..46b03c9dc 100644 --- a/src/server/output.rs +++ b/src/server/output.rs @@ -151,10 +151,9 @@ impl Output { let version = resp.version().unwrap_or_else(|| req.version); let mut len = 0; - #[cfg_attr(feature = "cargo-clippy", allow(match_ref_pats))] let has_body = match resp.body() { - &Body::Empty => false, - &Body::Binary(ref bin) => { + Body::Empty => false, + Body::Binary(ref bin) => { len = bin.len(); !(response_encoding == ContentEncoding::Auto && len < 96) } @@ -190,16 +189,15 @@ impl Output { #[cfg(not(any(feature = "brotli", feature = "flate2")))] let mut encoding = ContentEncoding::Identity; - #[cfg_attr(feature = "cargo-clippy", allow(match_ref_pats))] let transfer = match resp.body() { - &Body::Empty => { + Body::Empty => { if !info.head { info.length = ResponseLength::Zero; } *self = Output::Empty(buf); return; } - &Body::Binary(_) => { + Body::Binary(_) => { #[cfg(any(feature = "brotli", feature = "flate2"))] { if !(encoding == ContentEncoding::Identity @@ -244,7 +242,7 @@ impl Output { } return; } - &Body::Streaming(_) | &Body::Actor(_) => { + Body::Streaming(_) | Body::Actor(_) => { if resp.upgrade() { if version == Version::HTTP_2 { error!("Connection upgrade is forbidden for HTTP/2"); @@ -441,7 +439,7 @@ impl ContentEncoder { } } - #[cfg_attr(feature = "cargo-clippy", allow(inline_always))] + #[cfg_attr(feature = "cargo-clippy", allow(clippy::inline_always))] #[inline(always)] pub fn write_eof(&mut self) -> Result { let encoder = @@ -483,7 +481,7 @@ impl ContentEncoder { } } - #[cfg_attr(feature = "cargo-clippy", allow(inline_always))] + #[cfg_attr(feature = "cargo-clippy", allow(clippy::inline_always))] #[inline(always)] pub fn write(&mut self, data: &[u8]) -> Result<(), io::Error> { match *self { diff --git a/src/server/settings.rs b/src/server/settings.rs index ac79e4a46..a50a07069 100644 --- a/src/server/settings.rs +++ b/src/server/settings.rs @@ -216,7 +216,7 @@ impl WorkerSettings { fn update_date(&self) { // Unsafe: WorkerSetting is !Sync and !Send - unsafe { (&mut *self.0.date.get()).0 = false }; + unsafe { (*self.0.date.get()).0 = false }; } } diff --git a/src/with.rs b/src/with.rs index 5e2c01414..c6d54dee8 100644 --- a/src/with.rs +++ b/src/with.rs @@ -12,7 +12,6 @@ trait FnWith: 'static { } impl R + 'static> FnWith for F { - #[cfg_attr(feature = "cargo-clippy", allow(boxed_local))] fn call_with(self: &Self, arg: T) -> R { (*self)(arg) } @@ -42,24 +41,6 @@ where fn create_with_config(self, T::Config) -> WithAsync; } -// impl WithFactory<(T1, T2, T3), S, R> for F -// where F: Fn(T1, T2, T3) -> R + 'static, -// T1: FromRequest + 'static, -// T2: FromRequest + 'static, -// T3: FromRequest + 'static, -// R: Responder + 'static, -// S: 'static, -// { -// fn create(self) -> With<(T1, T2, T3), S, R> { -// With::new(move |(t1, t2, t3)| (self)(t1, t2, t3), ( -// T1::Config::default(), T2::Config::default(), T3::Config::default())) -// } - -// fn create_with_config(self, cfg: (T1::Config, T2::Config, T3::Config,)) -> With<(T1, T2, T3), S, R> { -// With::new(move |(t1, t2, t3)| (self)(t1, t2, t3), cfg) -// } -// } - #[doc(hidden)] pub struct With where diff --git a/src/ws/frame.rs b/src/ws/frame.rs index 5e4fd8290..d5fa98272 100644 --- a/src/ws/frame.rs +++ b/src/ws/frame.rs @@ -46,7 +46,7 @@ impl Frame { Frame::message(payload, OpCode::Close, true, genmask) } - #[cfg_attr(feature = "cargo-clippy", allow(type_complexity))] + #[cfg_attr(feature = "cargo-clippy", allow(clippy::type_complexity))] fn read_copy_md( pl: &mut PayloadBuffer, server: bool, max_size: usize, ) -> Poll)>, ProtocolError> diff --git a/src/ws/mask.rs b/src/ws/mask.rs index e9bfb3d56..a88c21afb 100644 --- a/src/ws/mask.rs +++ b/src/ws/mask.rs @@ -1,5 +1,5 @@ //! This is code from [Tungstenite project](https://github.com/snapview/tungstenite-rs) -#![cfg_attr(feature = "cargo-clippy", allow(cast_ptr_alignment))] +#![cfg_attr(feature = "cargo-clippy", allow(clippy::cast_ptr_alignment))] use std::ptr::copy_nonoverlapping; use std::slice; @@ -19,7 +19,7 @@ impl<'a> ShortSlice<'a> { /// Faster version of `apply_mask()` which operates on 8-byte blocks. #[inline] -#[cfg_attr(feature = "cargo-clippy", allow(cast_lossless))] +#[cfg_attr(feature = "cargo-clippy", allow(clippy::cast_lossless))] pub(crate) fn apply_mask(buf: &mut [u8], mask_u32: u32) { // Extend the mask to 64 bits let mut mask_u64 = ((mask_u32 as u64) << 32) | (mask_u32 as u64); @@ -50,7 +50,10 @@ pub(crate) fn apply_mask(buf: &mut [u8], mask_u32: u32) { // TODO: copy_nonoverlapping here compiles to call memcpy. While it is not so // inefficient, it could be done better. The compiler does not understand that // a `ShortSlice` must be smaller than a u64. -#[cfg_attr(feature = "cargo-clippy", allow(needless_pass_by_value))] +#[cfg_attr( + feature = "cargo-clippy", + allow(clippy::needless_pass_by_value) +)] fn xor_short(buf: ShortSlice, mask: u64) { // Unsafe: we know that a `ShortSlice` fits in a u64 unsafe {