diff --git a/actix-http/src/body.rs b/actix-http/src/body.rs index ff7235626..ecb12fc23 100644 --- a/actix-http/src/body.rs +++ b/actix-http/src/body.rs @@ -35,7 +35,7 @@ impl BodySize { pub trait MessageBody { fn size(&self) -> BodySize; - fn poll_next(&mut self, cx: &mut Context) -> Poll>>; + fn poll_next(&mut self, cx: &mut Context<'_>) -> Poll>>; } impl MessageBody for () { @@ -43,7 +43,7 @@ impl MessageBody for () { BodySize::Empty } - fn poll_next(&mut self, _: &mut Context) -> Poll>> { + fn poll_next(&mut self, _: &mut Context<'_>) -> Poll>> { Poll::Ready(None) } } @@ -53,7 +53,7 @@ impl MessageBody for Box { self.as_ref().size() } - fn poll_next(&mut self, cx: &mut Context) -> Poll>> { + fn poll_next(&mut self, cx: &mut Context<'_>) -> Poll>> { self.as_mut().poll_next(cx) } } @@ -97,7 +97,7 @@ impl MessageBody for ResponseBody { } } - fn poll_next(&mut self, cx: &mut Context) -> Poll>> { + fn poll_next(&mut self, cx: &mut Context<'_>) -> Poll>> { match self { ResponseBody::Body(ref mut body) => body.poll_next(cx), ResponseBody::Other(ref mut body) => body.poll_next(cx), @@ -109,7 +109,10 @@ impl Stream for ResponseBody { type Item = Result; #[project] - fn poll_next(self: Pin<&mut Self>, cx: &mut Context) -> Poll> { + fn poll_next( + self: Pin<&mut Self>, + cx: &mut Context<'_>, + ) -> Poll> { #[project] match self.project() { ResponseBody::Body(ref mut body) => body.poll_next(cx), @@ -152,7 +155,7 @@ impl MessageBody for Body { } } - fn poll_next(&mut self, cx: &mut Context) -> Poll>> { + fn poll_next(&mut self, cx: &mut Context<'_>) -> Poll>> { match self { Body::None => Poll::Ready(None), Body::Empty => Poll::Ready(None), @@ -190,7 +193,7 @@ impl PartialEq for Body { } impl fmt::Debug for Body { - fn fmt(&self, f: &mut fmt::Formatter) -> fmt::Result { + fn fmt(&self, f: &mut fmt::Formatter<'_>) -> fmt::Result { match *self { Body::None => write!(f, "Body::None"), Body::Empty => write!(f, "Body::Empty"), @@ -272,7 +275,7 @@ impl MessageBody for Bytes { BodySize::Sized(self.len()) } - fn poll_next(&mut self, _: &mut Context) -> Poll>> { + fn poll_next(&mut self, _: &mut Context<'_>) -> Poll>> { if self.is_empty() { Poll::Ready(None) } else { @@ -286,7 +289,7 @@ impl MessageBody for BytesMut { BodySize::Sized(self.len()) } - fn poll_next(&mut self, _: &mut Context) -> Poll>> { + fn poll_next(&mut self, _: &mut Context<'_>) -> Poll>> { if self.is_empty() { Poll::Ready(None) } else { @@ -300,7 +303,7 @@ impl MessageBody for &'static str { BodySize::Sized(self.len()) } - fn poll_next(&mut self, _: &mut Context) -> Poll>> { + fn poll_next(&mut self, _: &mut Context<'_>) -> Poll>> { if self.is_empty() { Poll::Ready(None) } else { @@ -316,7 +319,7 @@ impl MessageBody for &'static [u8] { BodySize::Sized(self.len()) } - fn poll_next(&mut self, _: &mut Context) -> Poll>> { + fn poll_next(&mut self, _: &mut Context<'_>) -> Poll>> { if self.is_empty() { Poll::Ready(None) } else { @@ -330,7 +333,7 @@ impl MessageBody for Vec { BodySize::Sized(self.len()) } - fn poll_next(&mut self, _: &mut Context) -> Poll>> { + fn poll_next(&mut self, _: &mut Context<'_>) -> Poll>> { if self.is_empty() { Poll::Ready(None) } else { @@ -344,7 +347,7 @@ impl MessageBody for String { BodySize::Sized(self.len()) } - fn poll_next(&mut self, _: &mut Context) -> Poll>> { + fn poll_next(&mut self, _: &mut Context<'_>) -> Poll>> { if self.is_empty() { Poll::Ready(None) } else { @@ -386,7 +389,7 @@ where BodySize::Stream } - fn poll_next(&mut self, cx: &mut Context) -> Poll>> { + fn poll_next(&mut self, cx: &mut Context<'_>) -> Poll>> { unsafe { Pin::new_unchecked(self) } .project() .stream @@ -421,7 +424,7 @@ where BodySize::Sized64(self.size) } - fn poll_next(&mut self, cx: &mut Context) -> Poll>> { + fn poll_next(&mut self, cx: &mut Context<'_>) -> Poll>> { unsafe { Pin::new_unchecked(self) } .project() .stream diff --git a/actix-http/src/client/connection.rs b/actix-http/src/client/connection.rs index 9b590690f..566769c5e 100644 --- a/actix-http/src/client/connection.rs +++ b/actix-http/src/client/connection.rs @@ -63,7 +63,7 @@ impl fmt::Debug for IoConnection where T: fmt::Debug, { - fn fmt(&self, f: &mut fmt::Formatter) -> fmt::Result { + fn fmt(&self, f: &mut fmt::Formatter<'_>) -> fmt::Result { match self.io { Some(ConnectionType::H1(ref io)) => write!(f, "H1Connection({:?})", io), Some(ConnectionType::H2(_)) => write!(f, "H2Connection"), @@ -247,7 +247,7 @@ where #[project] fn poll_write( self: Pin<&mut Self>, - cx: &mut Context, + cx: &mut Context<'_>, buf: &[u8], ) -> Poll> { #[project] diff --git a/actix-http/src/client/connector.rs b/actix-http/src/client/connector.rs index c78597d01..a06afa7b0 100644 --- a/actix-http/src/client/connector.rs +++ b/actix-http/src/client/connector.rs @@ -62,7 +62,7 @@ trait Io: AsyncRead + AsyncWrite + Unpin {} impl Io for T {} impl Connector<(), ()> { - #[allow(clippy::new_ret_no_self)] + #[allow(clippy::new_ret_no_self, clippy::let_unit_value)] pub fn new() -> Connector< impl Service< Request = TcpConnect, @@ -378,7 +378,7 @@ mod connect_impl { Ready, ConnectError>>, >; - fn poll_ready(&mut self, cx: &mut Context) -> Poll> { + fn poll_ready(&mut self, cx: &mut Context<'_>) -> Poll> { self.tcp_pool.poll_ready(cx) } @@ -451,7 +451,7 @@ mod connect_impl { InnerConnectorResponseB, >; - fn poll_ready(&mut self, cx: &mut Context) -> Poll> { + fn poll_ready(&mut self, cx: &mut Context<'_>) -> Poll> { self.tcp_pool.poll_ready(cx) } @@ -490,10 +490,10 @@ mod connect_impl { { type Output = Result, ConnectError>; - fn poll(self: Pin<&mut Self>, cx: &mut Context) -> Poll { + fn poll(self: Pin<&mut Self>, cx: &mut Context<'_>) -> Poll { Poll::Ready( ready!(Pin::new(&mut self.get_mut().fut).poll(cx)) - .map(|res| EitherConnection::A(res)), + .map(EitherConnection::A), ) } } @@ -519,10 +519,10 @@ mod connect_impl { { type Output = Result, ConnectError>; - fn poll(self: Pin<&mut Self>, cx: &mut Context) -> Poll { + fn poll(self: Pin<&mut Self>, cx: &mut Context<'_>) -> Poll { Poll::Ready( ready!(Pin::new(&mut self.get_mut().fut).poll(cx)) - .map(|res| EitherConnection::B(res)), + .map(EitherConnection::B), ) } } diff --git a/actix-http/src/client/h1proto.rs b/actix-http/src/client/h1proto.rs index 048d3795c..db4dede71 100644 --- a/actix-http/src/client/h1proto.rs +++ b/actix-http/src/client/h1proto.rs @@ -234,7 +234,7 @@ impl AsyncWrite for H1Connection fn poll_shutdown( mut self: Pin<&mut Self>, - cx: &mut Context, + cx: &mut Context<'_>, ) -> Poll> { Pin::new(self.io.as_mut().unwrap()).poll_shutdown(cx) } @@ -255,7 +255,10 @@ impl PlStream { impl Stream for PlStream { 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> { let this = self.get_mut(); match this.framed.as_mut().unwrap().next_item(cx)? { diff --git a/actix-http/src/client/pool.rs b/actix-http/src/client/pool.rs index ef5bd5965..0346c0614 100644 --- a/actix-http/src/client/pool.rs +++ b/actix-http/src/client/pool.rs @@ -93,7 +93,7 @@ where type Error = ConnectError; type Future = LocalBoxFuture<'static, Result, ConnectError>>; - fn poll_ready(&mut self, cx: &mut Context) -> Poll> { + fn poll_ready(&mut self, cx: &mut Context<'_>) -> Poll> { self.0.poll_ready(cx) } @@ -308,7 +308,7 @@ where (rx, token) } - fn acquire(&mut self, key: &Key, cx: &mut Context) -> Acquire { + fn acquire(&mut self, key: &Key, cx: &mut Context<'_>) -> Acquire { // check limits if self.limit > 0 && self.acquired >= self.limit { return Acquire::NotAvailable; @@ -409,7 +409,7 @@ where { type Output = (); - fn poll(self: Pin<&mut Self>, cx: &mut Context) -> Poll<()> { + fn poll(self: Pin<&mut Self>, cx: &mut Context<'_>) -> Poll<()> { let this = self.get_mut(); match Pin::new(&mut this.timeout).poll(cx) { @@ -438,7 +438,7 @@ where { type Output = (); - fn poll(self: Pin<&mut Self>, cx: &mut Context) -> Poll { + fn poll(self: Pin<&mut Self>, cx: &mut Context<'_>) -> Poll { let this = unsafe { self.get_unchecked_mut() }; let mut inner = this.inner.as_ref().borrow_mut(); @@ -545,7 +545,7 @@ where { type Output = (); - fn poll(self: Pin<&mut Self>, cx: &mut Context) -> Poll { + fn poll(self: Pin<&mut Self>, cx: &mut Context<'_>) -> Poll { let this = unsafe { self.get_unchecked_mut() }; if let Some(ref mut h2) = this.h2 { diff --git a/actix-http/src/cloneable.rs b/actix-http/src/cloneable.rs index 18869c66d..90d198b9c 100644 --- a/actix-http/src/cloneable.rs +++ b/actix-http/src/cloneable.rs @@ -32,7 +32,7 @@ where type Error = T::Error; type Future = T::Future; - fn poll_ready(&mut self, cx: &mut Context) -> Poll> { + fn poll_ready(&mut self, cx: &mut Context<'_>) -> Poll> { unsafe { &mut *self.0.as_ref().get() }.poll_ready(cx) } diff --git a/actix-http/src/cookie/draft.rs b/actix-http/src/cookie/draft.rs index 362133946..a2b039121 100644 --- a/actix-http/src/cookie/draft.rs +++ b/actix-http/src/cookie/draft.rs @@ -88,7 +88,7 @@ impl SameSite { } impl fmt::Display for SameSite { - fn fmt(&self, f: &mut fmt::Formatter) -> fmt::Result { + fn fmt(&self, f: &mut fmt::Formatter<'_>) -> fmt::Result { match *self { SameSite::Strict => write!(f, "Strict"), SameSite::Lax => write!(f, "Lax"), diff --git a/actix-http/src/cookie/jar.rs b/actix-http/src/cookie/jar.rs index cc67536c6..91af49320 100644 --- a/actix-http/src/cookie/jar.rs +++ b/actix-http/src/cookie/jar.rs @@ -307,7 +307,7 @@ impl CookieJar { /// // Delta contains two new cookies ("new", "yac") and a removal ("name"). /// assert_eq!(jar.delta().count(), 3); /// ``` - pub fn delta(&self) -> Delta { + pub fn delta(&self) -> Delta<'_> { Delta { iter: self.delta_cookies.iter(), } @@ -343,7 +343,7 @@ impl CookieJar { /// } /// } /// ``` - pub fn iter(&self) -> Iter { + pub fn iter(&self) -> Iter<'_> { Iter { delta_cookies: self .delta_cookies @@ -386,7 +386,7 @@ impl CookieJar { /// assert!(jar.get("private").is_some()); /// ``` #[cfg(feature = "secure-cookies")] - pub fn private(&mut self, key: &Key) -> PrivateJar { + pub fn private(&mut self, key: &Key) -> PrivateJar<'_> { PrivateJar::new(self, key) } @@ -424,7 +424,7 @@ impl CookieJar { /// assert!(jar.get("signed").is_some()); /// ``` #[cfg(feature = "secure-cookies")] - pub fn signed(&mut self, key: &Key) -> SignedJar { + pub fn signed(&mut self, key: &Key) -> SignedJar<'_> { SignedJar::new(self, key) } } diff --git a/actix-http/src/cookie/mod.rs b/actix-http/src/cookie/mod.rs index db8211427..cd150337d 100644 --- a/actix-http/src/cookie/mod.rs +++ b/actix-http/src/cookie/mod.rs @@ -110,7 +110,7 @@ impl CookieStr { /// # Panics /// /// Panics if `self` is an indexed string and `string` is None. - fn to_str<'s>(&'s self, string: Option<&'s Cow>) -> &'s str { + fn to_str<'s>(&'s self, string: Option<&'s Cow<'_, str>>) -> &'s str { match *self { CookieStr::Indexed(i, j) => { let s = string.expect( @@ -742,7 +742,7 @@ impl<'c> Cookie<'c> { self.set_expires(time::now() + twenty_years); } - fn fmt_parameters(&self, f: &mut fmt::Formatter) -> fmt::Result { + fn fmt_parameters(&self, f: &mut fmt::Formatter<'_>) -> fmt::Result { if let Some(true) = self.http_only() { write!(f, "; HttpOnly")?; } @@ -924,10 +924,10 @@ impl<'c> Cookie<'c> { /// let mut c = Cookie::new("my name", "this; value?"); /// assert_eq!(&c.encoded().to_string(), "my%20name=this%3B%20value%3F"); /// ``` -pub struct EncodedCookie<'a, 'c: 'a>(&'a Cookie<'c>); +pub struct EncodedCookie<'a, 'c>(&'a Cookie<'c>); impl<'a, 'c: 'a> fmt::Display for EncodedCookie<'a, 'c> { - fn fmt(&self, f: &mut fmt::Formatter) -> fmt::Result { + fn fmt(&self, f: &mut fmt::Formatter<'_>) -> fmt::Result { // Percent-encode the name and value. let name = percent_encode(self.0.name().as_bytes(), USERINFO); let value = percent_encode(self.0.value().as_bytes(), USERINFO); @@ -952,7 +952,7 @@ impl<'c> fmt::Display for Cookie<'c> { /// /// assert_eq!(&cookie.to_string(), "foo=bar; Path=/"); /// ``` - fn fmt(&self, f: &mut fmt::Formatter) -> fmt::Result { + fn fmt(&self, f: &mut fmt::Formatter<'_>) -> fmt::Result { write!(f, "{}={}", self.name(), self.value())?; self.fmt_parameters(f) } diff --git a/actix-http/src/cookie/parse.rs b/actix-http/src/cookie/parse.rs index 42a2c1fcf..8c9d4b644 100644 --- a/actix-http/src/cookie/parse.rs +++ b/actix-http/src/cookie/parse.rs @@ -40,7 +40,7 @@ impl ParseError { } impl fmt::Display for ParseError { - fn fmt(&self, f: &mut fmt::Formatter) -> fmt::Result { + fn fmt(&self, f: &mut fmt::Formatter<'_>) -> fmt::Result { write!(f, "{}", self.as_str()) } } diff --git a/actix-http/src/cookie/secure/private.rs b/actix-http/src/cookie/secure/private.rs index 6c16e94e8..f05e23800 100644 --- a/actix-http/src/cookie/secure/private.rs +++ b/actix-http/src/cookie/secure/private.rs @@ -10,7 +10,7 @@ use crate::cookie::{Cookie, CookieJar}; // Keep these in sync, and keep the key len synced with the `private` docs as // well as the `KEYS_INFO` const in secure::Key. -static ALGO: &'static Algorithm = &AES_256_GCM; +static ALGO: &Algorithm = &AES_256_GCM; const NONCE_LEN: usize = 12; pub const KEY_LEN: usize = 32; @@ -159,7 +159,7 @@ Please change it as soon as possible." /// Encrypts the cookie's value with /// authenticated encryption assuring confidentiality, integrity, and authenticity. - fn encrypt_cookie(&self, cookie: &mut Cookie) { + fn encrypt_cookie(&self, cookie: &mut Cookie<'_>) { let name = cookie.name().as_bytes(); let value = cookie.value().as_bytes(); let data = encrypt_name_value(name, value, &self.key); diff --git a/actix-http/src/cookie/secure/signed.rs b/actix-http/src/cookie/secure/signed.rs index 3fcd2cd84..64e8d5dda 100644 --- a/actix-http/src/cookie/secure/signed.rs +++ b/actix-http/src/cookie/secure/signed.rs @@ -129,7 +129,7 @@ impl<'a> SignedJar<'a> { } /// Signs the cookie's value assuring integrity and authenticity. - fn sign_cookie(&self, cookie: &mut Cookie) { + fn sign_cookie(&self, cookie: &mut Cookie<'_>) { let digest = sign(&self.key, cookie.value().as_bytes()); let mut new_value = base64::encode(digest.as_ref()); new_value.push_str(cookie.value()); diff --git a/actix-http/src/encoding/decoder.rs b/actix-http/src/encoding/decoder.rs index 90199b4f7..35be2d13c 100644 --- a/actix-http/src/encoding/decoder.rs +++ b/actix-http/src/encoding/decoder.rs @@ -78,7 +78,7 @@ where fn poll_next( mut self: Pin<&mut Self>, - cx: &mut Context, + cx: &mut Context<'_>, ) -> Poll> { loop { if let Some(ref mut fut) = self.fut { diff --git a/actix-http/src/encoding/encoder.rs b/actix-http/src/encoding/encoder.rs index d06762787..f8f996ff1 100644 --- a/actix-http/src/encoding/encoder.rs +++ b/actix-http/src/encoding/encoder.rs @@ -95,7 +95,7 @@ impl MessageBody for Encoder { } } - fn poll_next(&mut self, cx: &mut Context) -> Poll>> { + fn poll_next(&mut self, cx: &mut Context<'_>) -> Poll>> { loop { if self.eof { return Poll::Ready(None); @@ -176,7 +176,7 @@ enum ContentEncoder { Deflate(ZlibEncoder), #[cfg(any(feature = "flate2-zlib", feature = "flate2-rust"))] Gzip(GzEncoder), - Br(CompressorWriter), + Br(Box>), } impl ContentEncoder { @@ -192,11 +192,8 @@ impl ContentEncoder { Writer::new(), flate2::Compression::fast(), ))), - ContentEncoding::Br => Some(ContentEncoder::Br(CompressorWriter::new( - Writer::new(), - 0, - 3, - 0, + ContentEncoding::Br => Some(ContentEncoder::Br(Box::new( + CompressorWriter::new(Writer::new(), 0, 3, 0), ))), _ => None, } @@ -206,7 +203,8 @@ impl ContentEncoder { pub(crate) fn take(&mut self) -> Bytes { match *self { ContentEncoder::Br(ref mut encoder) => { - let mut encoder_new = CompressorWriter::new(Writer::new(), 0, 3, 0); + let mut encoder_new = + Box::new(CompressorWriter::new(Writer::new(), 0, 3, 0)); std::mem::swap(encoder, &mut encoder_new); encoder_new.into_inner().freeze() } diff --git a/actix-http/src/error.rs b/actix-http/src/error.rs index ec56900fc..1dca55902 100644 --- a/actix-http/src/error.rs +++ b/actix-http/src/error.rs @@ -102,13 +102,13 @@ impl dyn ResponseError + 'static { } impl fmt::Display for Error { - fn fmt(&self, f: &mut fmt::Formatter) -> fmt::Result { + fn fmt(&self, f: &mut fmt::Formatter<'_>) -> fmt::Result { fmt::Display::fmt(&self.cause, f) } } impl fmt::Debug for Error { - fn fmt(&self, f: &mut fmt::Formatter) -> fmt::Result { + fn fmt(&self, f: &mut fmt::Formatter<'_>) -> fmt::Result { writeln!(f, "{:?}", &self.cause) } } @@ -515,7 +515,7 @@ impl fmt::Debug for InternalError where T: fmt::Debug + 'static, { - fn fmt(&self, f: &mut fmt::Formatter) -> fmt::Result { + fn fmt(&self, f: &mut fmt::Formatter<'_>) -> fmt::Result { fmt::Debug::fmt(&self.cause, f) } } @@ -524,7 +524,7 @@ impl fmt::Display for InternalError where T: fmt::Display + 'static, { - fn fmt(&self, f: &mut fmt::Formatter) -> fmt::Result { + fn fmt(&self, f: &mut fmt::Formatter<'_>) -> fmt::Result { fmt::Display::fmt(&self.cause, f) } } diff --git a/actix-http/src/extensions.rs b/actix-http/src/extensions.rs index 066e0a3ca..d85ca184d 100644 --- a/actix-http/src/extensions.rs +++ b/actix-http/src/extensions.rs @@ -65,7 +65,7 @@ impl Extensions { } impl fmt::Debug for Extensions { - fn fmt(&self, f: &mut fmt::Formatter) -> fmt::Result { + fn fmt(&self, f: &mut fmt::Formatter<'_>) -> fmt::Result { f.debug_struct("Extensions").finish() } } diff --git a/actix-http/src/h1/codec.rs b/actix-http/src/h1/codec.rs index 22c7ed232..726d1c97f 100644 --- a/actix-http/src/h1/codec.rs +++ b/actix-http/src/h1/codec.rs @@ -49,7 +49,7 @@ impl Default for Codec { } impl fmt::Debug for Codec { - fn fmt(&self, f: &mut fmt::Formatter) -> fmt::Result { + fn fmt(&self, f: &mut fmt::Formatter<'_>) -> fmt::Result { write!(f, "h1::Codec({:?})", self.flags) } } diff --git a/actix-http/src/h1/decoder.rs b/actix-http/src/h1/decoder.rs index 32ec64ba3..87e2a1ec8 100644 --- a/actix-http/src/h1/decoder.rs +++ b/actix-http/src/h1/decoder.rs @@ -185,6 +185,7 @@ impl MessageType for Request { &mut self.head_mut().headers } + #[allow(clippy::uninit_assumed_init)] fn decode(src: &mut BytesMut) -> Result, ParseError> { // Unsafe: we read only this data only after httparse parses headers into. // performance bump for pipeline benchmarks. @@ -192,7 +193,7 @@ impl MessageType for Request { unsafe { MaybeUninit::uninit().assume_init() }; let (len, method, uri, ver, h_len) = { - let mut parsed: [httparse::Header; MAX_HEADERS] = + let mut parsed: [httparse::Header<'_>; MAX_HEADERS] = unsafe { MaybeUninit::uninit().assume_init() }; let mut req = httparse::Request::new(&mut parsed); @@ -260,6 +261,7 @@ impl MessageType for ResponseHead { &mut self.headers } + #[allow(clippy::uninit_assumed_init)] fn decode(src: &mut BytesMut) -> Result, ParseError> { // Unsafe: we read only this data only after httparse parses headers into. // performance bump for pipeline benchmarks. @@ -267,7 +269,7 @@ impl MessageType for ResponseHead { unsafe { MaybeUninit::uninit().assume_init() }; let (len, ver, status, h_len) = { - let mut parsed: [httparse::Header; MAX_HEADERS] = + let mut parsed: [httparse::Header<'_>; MAX_HEADERS] = unsafe { MaybeUninit::uninit().assume_init() }; let mut res = httparse::Response::new(&mut parsed); @@ -326,7 +328,7 @@ pub(crate) struct HeaderIndex { impl HeaderIndex { pub(crate) fn record( bytes: &[u8], - headers: &[httparse::Header], + headers: &[httparse::Header<'_>], indices: &mut [HeaderIndex], ) { let bytes_ptr = bytes.as_ptr() as usize; diff --git a/actix-http/src/h1/dispatcher.rs b/actix-http/src/h1/dispatcher.rs index 0e2a58346..7276d5a38 100644 --- a/actix-http/src/h1/dispatcher.rs +++ b/actix-http/src/h1/dispatcher.rs @@ -264,7 +264,7 @@ where U: Service), Response = ()>, U::Error: fmt::Display, { - fn can_read(&self, cx: &mut Context) -> bool { + fn can_read(&self, cx: &mut Context<'_>) -> bool { if self .flags .intersects(Flags::READ_DISCONNECT | Flags::UPGRADE) @@ -290,7 +290,7 @@ where /// /// true - got whouldblock /// false - didnt get whouldblock - fn poll_flush(&mut self, cx: &mut Context) -> Result { + fn poll_flush(&mut self, cx: &mut Context<'_>) -> Result { if self.write_buf.is_empty() { return Ok(false); } @@ -355,7 +355,7 @@ where fn poll_response( &mut self, - cx: &mut Context, + cx: &mut Context<'_>, ) -> Result { loop { let state = match self.state { @@ -459,7 +459,7 @@ where fn handle_request( &mut self, req: Request, - cx: &mut Context, + cx: &mut Context<'_>, ) -> Result, DispatchError> { // Handle `EXPECT: 100-Continue` header let req = if req.head().expect() { @@ -500,7 +500,7 @@ where /// Process one incoming requests pub(self) fn poll_request( &mut self, - cx: &mut Context, + cx: &mut Context<'_>, ) -> Result { // limit a mount of non processed requests if self.messages.len() >= MAX_PIPELINED_MESSAGES || !self.can_read(cx) { @@ -604,7 +604,7 @@ where } /// keep-alive timer - fn poll_keepalive(&mut self, cx: &mut Context) -> Result<(), DispatchError> { + fn poll_keepalive(&mut self, cx: &mut Context<'_>) -> Result<(), DispatchError> { if self.ka_timer.is_none() { // shutdown timeout if self.flags.contains(Flags::SHUTDOWN) { @@ -710,7 +710,7 @@ where type Output = Result<(), DispatchError>; #[inline] - fn poll(mut self: Pin<&mut Self>, cx: &mut Context) -> Poll { + fn poll(mut self: Pin<&mut Self>, cx: &mut Context<'_>) -> Poll { match self.as_mut().inner { DispatcherState::Normal(ref mut inner) => { inner.poll_keepalive(cx)?; @@ -832,7 +832,7 @@ where } fn read_available( - cx: &mut Context, + cx: &mut Context<'_>, io: &mut T, buf: &mut BytesMut, ) -> Result, io::Error> @@ -874,7 +874,7 @@ where } fn read( - cx: &mut Context, + cx: &mut Context<'_>, io: &mut T, buf: &mut BytesMut, ) -> Poll> diff --git a/actix-http/src/h1/expect.rs b/actix-http/src/h1/expect.rs index 109491bac..187999358 100644 --- a/actix-http/src/h1/expect.rs +++ b/actix-http/src/h1/expect.rs @@ -28,7 +28,7 @@ impl Service for ExpectHandler { type Error = Error; type Future = Ready>; - fn poll_ready(&mut self, _: &mut Context) -> Poll> { + fn poll_ready(&mut self, _: &mut Context<'_>) -> Poll> { Poll::Ready(Ok(())) } diff --git a/actix-http/src/h1/payload.rs b/actix-http/src/h1/payload.rs index 46f2f9728..abf42dc89 100644 --- a/actix-http/src/h1/payload.rs +++ b/actix-http/src/h1/payload.rs @@ -82,7 +82,7 @@ impl Payload { #[inline] pub fn readany( &mut self, - cx: &mut Context, + cx: &mut Context<'_>, ) -> Poll>> { self.inner.borrow_mut().readany(cx) } @@ -93,7 +93,7 @@ impl Stream for Payload { fn poll_next( self: Pin<&mut Self>, - cx: &mut Context, + cx: &mut Context<'_>, ) -> Poll>> { self.inner.borrow_mut().readany(cx) } @@ -127,7 +127,7 @@ impl PayloadSender { } #[inline] - pub fn need_read(&self, cx: &mut Context) -> PayloadStatus { + pub fn need_read(&self, cx: &mut Context<'_>) -> PayloadStatus { // we check need_read only if Payload (other side) is alive, // otherwise always return true (consume payload) if let Some(shared) = self.inner.upgrade() { @@ -194,7 +194,7 @@ impl Inner { fn readany( &mut self, - cx: &mut Context, + cx: &mut Context<'_>, ) -> Poll>> { if let Some(data) = self.items.pop_front() { self.len -= data.len(); diff --git a/actix-http/src/h1/service.rs b/actix-http/src/h1/service.rs index d6494b5cb..6d5123843 100644 --- a/actix-http/src/h1/service.rs +++ b/actix-http/src/h1/service.rs @@ -324,7 +324,7 @@ where { type Output = Result, ()>; - fn poll(mut self: Pin<&mut Self>, cx: &mut Context) -> Poll { + fn poll(mut self: Pin<&mut Self>, cx: &mut Context<'_>) -> Poll { let mut this = self.as_mut().project(); if let Some(fut) = this.fut_ex.as_pin_mut() { @@ -419,7 +419,7 @@ where type Error = DispatchError; type Future = Dispatcher; - fn poll_ready(&mut self, cx: &mut Context) -> Poll> { + fn poll_ready(&mut self, cx: &mut Context<'_>) -> Poll> { let ready = self .expect .poll_ready(cx) @@ -523,7 +523,7 @@ where type Error = ParseError; type Future = OneRequestServiceResponse; - fn poll_ready(&mut self, _: &mut Context) -> Poll> { + fn poll_ready(&mut self, _: &mut Context<'_>) -> Poll> { Poll::Ready(Ok(())) } @@ -548,7 +548,7 @@ where { type Output = Result<(Request, Framed), ParseError>; - fn poll(mut self: Pin<&mut Self>, cx: &mut Context) -> Poll { + fn poll(mut self: Pin<&mut Self>, cx: &mut Context<'_>) -> Poll { match self.framed.as_mut().unwrap().next_item(cx) { Poll::Ready(Some(Ok(req))) => match req { Message::Item(req) => { diff --git a/actix-http/src/h1/upgrade.rs b/actix-http/src/h1/upgrade.rs index e3ce66521..d02d4f075 100644 --- a/actix-http/src/h1/upgrade.rs +++ b/actix-http/src/h1/upgrade.rs @@ -31,7 +31,7 @@ impl Service for UpgradeHandler { type Error = Error; type Future = Ready>; - fn poll_ready(&mut self, _: &mut Context) -> Poll> { + fn poll_ready(&mut self, _: &mut Context<'_>) -> Poll> { Poll::Ready(Ok(())) } diff --git a/actix-http/src/h1/utils.rs b/actix-http/src/h1/utils.rs index 7af0b124e..9ba4aa053 100644 --- a/actix-http/src/h1/utils.rs +++ b/actix-http/src/h1/utils.rs @@ -39,7 +39,7 @@ where { type Output = Result, Error>; - fn poll(self: Pin<&mut Self>, cx: &mut Context) -> Poll { + fn poll(self: Pin<&mut Self>, cx: &mut Context<'_>) -> Poll { let this = self.get_mut(); loop { diff --git a/actix-http/src/h2/dispatcher.rs b/actix-http/src/h2/dispatcher.rs index 707ac7b9d..b827762cb 100644 --- a/actix-http/src/h2/dispatcher.rs +++ b/actix-http/src/h2/dispatcher.rs @@ -106,7 +106,7 @@ where type Output = Result<(), DispatchError>; #[inline] - fn poll(self: Pin<&mut Self>, cx: &mut Context) -> Poll { + fn poll(self: Pin<&mut Self>, cx: &mut Context<'_>) -> Poll { let this = self.get_mut(); loop { @@ -252,7 +252,7 @@ where { type Output = (); - fn poll(mut self: Pin<&mut Self>, cx: &mut Context) -> Poll { + fn poll(mut self: Pin<&mut Self>, cx: &mut Context<'_>) -> Poll { let mut this = self.as_mut().project(); match this.state { diff --git a/actix-http/src/h2/mod.rs b/actix-http/src/h2/mod.rs index 28dd75383..21080c69a 100644 --- a/actix-http/src/h2/mod.rs +++ b/actix-http/src/h2/mod.rs @@ -29,7 +29,10 @@ impl Payload { impl Stream for Payload { 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> { let this = self.get_mut(); match Pin::new(&mut this.pl).poll_data(cx) { diff --git a/actix-http/src/h2/service.rs b/actix-http/src/h2/service.rs index 1bacc5c95..cdef71c57 100644 --- a/actix-http/src/h2/service.rs +++ b/actix-http/src/h2/service.rs @@ -235,7 +235,7 @@ where { type Output = Result, S::InitError>; - fn poll(mut self: Pin<&mut Self>, cx: &mut Context) -> Poll { + fn poll(mut self: Pin<&mut Self>, cx: &mut Context<'_>) -> Poll { let this = self.as_mut().project(); Poll::Ready(ready!(this.fut.poll(cx)).map(|service| { @@ -293,7 +293,7 @@ where type Error = DispatchError; type Future = H2ServiceHandlerResponse; - fn poll_ready(&mut self, cx: &mut Context) -> Poll> { + fn poll_ready(&mut self, cx: &mut Context<'_>) -> Poll> { self.srv.poll_ready(cx).map_err(|e| { let e = e.into(); error!("Service readiness error: {:?}", e); @@ -358,7 +358,7 @@ where { type Output = Result<(), DispatchError>; - fn poll(mut self: Pin<&mut Self>, cx: &mut Context) -> Poll { + fn poll(mut self: Pin<&mut Self>, cx: &mut Context<'_>) -> Poll { match self.state { State::Incoming(ref mut disp) => Pin::new(disp).poll(cx), State::Handshake( diff --git a/actix-http/src/header/common/cache_control.rs b/actix-http/src/header/common/cache_control.rs index a3253b85b..ec94ce4a9 100644 --- a/actix-http/src/header/common/cache_control.rs +++ b/actix-http/src/header/common/cache_control.rs @@ -74,7 +74,7 @@ impl Header for CacheControl { } impl fmt::Display for CacheControl { - fn fmt(&self, f: &mut fmt::Formatter) -> fmt::Result { + fn fmt(&self, f: &mut fmt::Formatter<'_>) -> fmt::Result { fmt_comma_delimited(f, &self[..]) } } @@ -126,7 +126,7 @@ pub enum CacheDirective { } impl fmt::Display for CacheDirective { - fn fmt(&self, f: &mut fmt::Formatter) -> fmt::Result { + fn fmt(&self, f: &mut fmt::Formatter<'_>) -> fmt::Result { use self::CacheDirective::*; fmt::Display::fmt( match *self { diff --git a/actix-http/src/header/common/content_disposition.rs b/actix-http/src/header/common/content_disposition.rs index d09024f3f..d0d5af765 100644 --- a/actix-http/src/header/common/content_disposition.rs +++ b/actix-http/src/header/common/content_disposition.rs @@ -486,7 +486,7 @@ impl Header for ContentDisposition { } impl fmt::Display for DispositionType { - fn fmt(&self, f: &mut fmt::Formatter) -> fmt::Result { + fn fmt(&self, f: &mut fmt::Formatter<'_>) -> fmt::Result { match self { DispositionType::Inline => write!(f, "inline"), DispositionType::Attachment => write!(f, "attachment"), @@ -497,7 +497,7 @@ impl fmt::Display for DispositionType { } impl fmt::Display for DispositionParam { - fn fmt(&self, f: &mut fmt::Formatter) -> fmt::Result { + fn fmt(&self, f: &mut fmt::Formatter<'_>) -> fmt::Result { // All ASCII control characters (0-30, 127) including horizontal tab, double quote, and // backslash should be escaped in quoted-string (i.e. "foobar"). // Ref: RFC6266 S4.1 -> RFC2616 S3.6 @@ -555,7 +555,7 @@ impl fmt::Display for DispositionParam { } impl fmt::Display for ContentDisposition { - fn fmt(&self, f: &mut fmt::Formatter) -> fmt::Result { + fn fmt(&self, f: &mut fmt::Formatter<'_>) -> fmt::Result { write!(f, "{}", self.disposition)?; self.parameters .iter() diff --git a/actix-http/src/header/common/content_range.rs b/actix-http/src/header/common/content_range.rs index a3e4d49ba..9a604c641 100644 --- a/actix-http/src/header/common/content_range.rs +++ b/actix-http/src/header/common/content_range.rs @@ -166,7 +166,7 @@ impl FromStr for ContentRangeSpec { } impl Display for ContentRangeSpec { - fn fmt(&self, f: &mut fmt::Formatter) -> fmt::Result { + fn fmt(&self, f: &mut fmt::Formatter<'_>) -> fmt::Result { match *self { ContentRangeSpec::Bytes { range, diff --git a/actix-http/src/header/common/if_range.rs b/actix-http/src/header/common/if_range.rs index ea5d69a13..b14ad0391 100644 --- a/actix-http/src/header/common/if_range.rs +++ b/actix-http/src/header/common/if_range.rs @@ -87,7 +87,7 @@ impl Header for IfRange { } impl Display for IfRange { - fn fmt(&self, f: &mut fmt::Formatter) -> fmt::Result { + fn fmt(&self, f: &mut fmt::Formatter<'_>) -> fmt::Result { match *self { IfRange::EntityTag(ref x) => Display::fmt(x, f), IfRange::Date(ref x) => Display::fmt(x, f), diff --git a/actix-http/src/header/common/mod.rs b/actix-http/src/header/common/mod.rs index 814050b13..08950ea8b 100644 --- a/actix-http/src/header/common/mod.rs +++ b/actix-http/src/header/common/mod.rs @@ -159,7 +159,7 @@ macro_rules! header { } impl std::fmt::Display for $id { #[inline] - fn fmt(&self, f: &mut std::fmt::Formatter) -> ::std::fmt::Result { + fn fmt(&self, f: &mut std::fmt::Formatter<'_>) -> ::std::fmt::Result { $crate::http::header::fmt_comma_delimited(f, &self.0[..]) } } @@ -195,7 +195,7 @@ macro_rules! header { } impl std::fmt::Display for $id { #[inline] - fn fmt(&self, f: &mut std::fmt::Formatter) -> std::fmt::Result { + fn fmt(&self, f: &mut std::fmt::Formatter<'_>) -> std::fmt::Result { $crate::http::header::fmt_comma_delimited(f, &self.0[..]) } } @@ -231,7 +231,7 @@ macro_rules! header { } impl std::fmt::Display for $id { #[inline] - fn fmt(&self, f: &mut std::fmt::Formatter) -> std::fmt::Result { + fn fmt(&self, f: &mut std::fmt::Formatter<'_>) -> std::fmt::Result { std::fmt::Display::fmt(&self.0, f) } } @@ -276,7 +276,7 @@ macro_rules! header { } impl std::fmt::Display for $id { #[inline] - fn fmt(&self, f: &mut std::fmt::Formatter) -> std::fmt::Result { + fn fmt(&self, f: &mut std::fmt::Formatter<'_>) -> std::fmt::Result { match *self { $id::Any => f.write_str("*"), $id::Items(ref fields) => $crate::http::header::fmt_comma_delimited( diff --git a/actix-http/src/header/map.rs b/actix-http/src/header/map.rs index dc49d53f3..132087b9e 100644 --- a/actix-http/src/header/map.rs +++ b/actix-http/src/header/map.rs @@ -143,7 +143,7 @@ impl HeaderMap { /// Returns `None` if there are no values associated with the key. /// /// [`GetAll`]: struct.GetAll.html - pub fn get_all(&self, name: N) -> GetAll { + pub fn get_all(&self, name: N) -> GetAll<'_> { GetAll { idx: 0, item: self.get2(name), @@ -187,7 +187,7 @@ impl HeaderMap { /// The iteration order is arbitrary, but consistent across platforms for /// the same crate version. Each key will be yielded once per associated /// value. So, if a key has 3 associated values, it will be yielded 3 times. - pub fn iter(&self) -> Iter { + pub fn iter(&self) -> Iter<'_> { Iter::new(self.inner.iter()) } @@ -196,7 +196,7 @@ impl HeaderMap { /// The iteration order is arbitrary, but consistent across platforms for /// the same crate version. Each key will be yielded only once even if it /// has multiple associated values. - pub fn keys(&self) -> Keys { + pub fn keys(&self) -> Keys<'_> { Keys(self.inner.keys()) } diff --git a/actix-http/src/header/mod.rs b/actix-http/src/header/mod.rs index 6fd3c1b96..0db26ceb0 100644 --- a/actix-http/src/header/mod.rs +++ b/actix-http/src/header/mod.rs @@ -217,7 +217,7 @@ impl fmt::Write for Writer { } #[inline] - fn write_fmt(&mut self, args: fmt::Arguments) -> fmt::Result { + fn write_fmt(&mut self, args: fmt::Arguments<'_>) -> fmt::Result { fmt::write(self, args) } } @@ -259,7 +259,7 @@ pub fn from_one_raw_str(val: Option<&HeaderValue>) -> Result(f: &mut fmt::Formatter, parts: &[T]) -> fmt::Result +pub fn fmt_comma_delimited(f: &mut fmt::Formatter<'_>, parts: &[T]) -> fmt::Result where T: fmt::Display, { @@ -361,7 +361,7 @@ pub fn parse_extended_value( } impl fmt::Display for ExtendedValue { - fn fmt(&self, f: &mut fmt::Formatter) -> fmt::Result { + fn fmt(&self, f: &mut fmt::Formatter<'_>) -> fmt::Result { let encoded_value = percent_encoding::percent_encode(&self.value[..], HTTP_VALUE); if let Some(ref lang) = self.language_tag { @@ -376,7 +376,7 @@ impl fmt::Display for ExtendedValue { /// [https://tools.ietf.org/html/rfc5987#section-3.2][url] /// /// [url]: https://tools.ietf.org/html/rfc5987#section-3.2 -pub fn http_percent_encode(f: &mut fmt::Formatter, bytes: &[u8]) -> fmt::Result { +pub fn http_percent_encode(f: &mut fmt::Formatter<'_>, bytes: &[u8]) -> fmt::Result { let encoded = percent_encoding::percent_encode(bytes, HTTP_VALUE); fmt::Display::fmt(&encoded, f) } diff --git a/actix-http/src/header/shared/charset.rs b/actix-http/src/header/shared/charset.rs index ec3fe3854..6ddfa03ea 100644 --- a/actix-http/src/header/shared/charset.rs +++ b/actix-http/src/header/shared/charset.rs @@ -98,7 +98,7 @@ impl Charset { } impl Display for Charset { - fn fmt(&self, f: &mut fmt::Formatter) -> fmt::Result { + fn fmt(&self, f: &mut fmt::Formatter<'_>) -> fmt::Result { f.write_str(self.label()) } } diff --git a/actix-http/src/header/shared/encoding.rs b/actix-http/src/header/shared/encoding.rs index af7404828..aa49dea45 100644 --- a/actix-http/src/header/shared/encoding.rs +++ b/actix-http/src/header/shared/encoding.rs @@ -27,7 +27,7 @@ pub enum Encoding { } impl fmt::Display for Encoding { - fn fmt(&self, f: &mut fmt::Formatter) -> fmt::Result { + fn fmt(&self, f: &mut fmt::Formatter<'_>) -> fmt::Result { f.write_str(match *self { Chunked => "chunked", Brotli => "br", diff --git a/actix-http/src/header/shared/entity.rs b/actix-http/src/header/shared/entity.rs index 7ef51a7d6..3525a19c6 100644 --- a/actix-http/src/header/shared/entity.rs +++ b/actix-http/src/header/shared/entity.rs @@ -113,7 +113,7 @@ impl EntityTag { } impl Display for EntityTag { - fn fmt(&self, f: &mut fmt::Formatter) -> fmt::Result { + fn fmt(&self, f: &mut fmt::Formatter<'_>) -> fmt::Result { if self.weak { write!(f, "W/\"{}\"", self.tag) } else { diff --git a/actix-http/src/header/shared/httpdate.rs b/actix-http/src/header/shared/httpdate.rs index c8d26ef54..28d6a25ec 100644 --- a/actix-http/src/header/shared/httpdate.rs +++ b/actix-http/src/header/shared/httpdate.rs @@ -28,7 +28,7 @@ impl FromStr for HttpDate { } impl Display for HttpDate { - fn fmt(&self, f: &mut fmt::Formatter) -> fmt::Result { + fn fmt(&self, f: &mut fmt::Formatter<'_>) -> fmt::Result { fmt::Display::fmt(&self.0.to_utc().rfc822(), f) } } diff --git a/actix-http/src/header/shared/quality_item.rs b/actix-http/src/header/shared/quality_item.rs index fc3930c5e..98230dec1 100644 --- a/actix-http/src/header/shared/quality_item.rs +++ b/actix-http/src/header/shared/quality_item.rs @@ -53,7 +53,7 @@ impl cmp::PartialOrd for QualityItem { } impl fmt::Display for QualityItem { - fn fmt(&self, f: &mut fmt::Formatter) -> fmt::Result { + fn fmt(&self, f: &mut fmt::Formatter<'_>) -> fmt::Result { fmt::Display::fmt(&self.item, f)?; match self.quality.0 { 1000 => Ok(()), diff --git a/actix-http/src/httpmessage.rs b/actix-http/src/httpmessage.rs index 05d668c10..e1c4136b0 100644 --- a/actix-http/src/httpmessage.rs +++ b/actix-http/src/httpmessage.rs @@ -25,10 +25,10 @@ pub trait HttpMessage: Sized { fn take_payload(&mut self) -> Payload; /// Request's extensions container - fn extensions(&self) -> Ref; + fn extensions(&self) -> Ref<'_, Extensions>; /// Mutable reference to a the request's extensions container - fn extensions_mut(&self) -> RefMut; + fn extensions_mut(&self) -> RefMut<'_, Extensions>; #[doc(hidden)] /// Get a header @@ -105,7 +105,7 @@ pub trait HttpMessage: Sized { /// Load request cookies. #[inline] - fn cookies(&self) -> Result>>, CookieParseError> { + fn cookies(&self) -> Result>>, CookieParseError> { if self.extensions().get::().is_none() { let mut cookies = Vec::new(); for hdr in self.headers().get_all(header::COOKIE) { @@ -153,12 +153,12 @@ where } /// Request's extensions container - fn extensions(&self) -> Ref { + fn extensions(&self) -> Ref<'_, Extensions> { (**self).extensions() } /// Mutable reference to a the request's extensions container - fn extensions_mut(&self) -> RefMut { + fn extensions_mut(&self) -> RefMut<'_, Extensions> { (**self).extensions_mut() } } diff --git a/actix-http/src/lib.rs b/actix-http/src/lib.rs index 190d5fbdc..1da074ad1 100644 --- a/actix-http/src/lib.rs +++ b/actix-http/src/lib.rs @@ -1,4 +1,5 @@ //! Basic http primitives for actix-net framework. +#![deny(rust_2018_idioms, warnings)] #![allow( clippy::type_complexity, clippy::too_many_arguments, diff --git a/actix-http/src/message.rs b/actix-http/src/message.rs index 5994ed39e..d005ad04a 100644 --- a/actix-http/src/message.rs +++ b/actix-http/src/message.rs @@ -78,13 +78,13 @@ impl Head for RequestHead { impl RequestHead { /// Message extensions #[inline] - pub fn extensions(&self) -> Ref { + pub fn extensions(&self) -> Ref<'_, Extensions> { self.extensions.borrow() } /// Mutable reference to a the message's extensions #[inline] - pub fn extensions_mut(&self) -> RefMut { + pub fn extensions_mut(&self) -> RefMut<'_, Extensions> { self.extensions.borrow_mut() } @@ -237,13 +237,13 @@ impl ResponseHead { /// Message extensions #[inline] - pub fn extensions(&self) -> Ref { + pub fn extensions(&self) -> Ref<'_, Extensions> { self.extensions.borrow() } /// Mutable reference to a the message's extensions #[inline] - pub fn extensions_mut(&self) -> RefMut { + pub fn extensions_mut(&self) -> RefMut<'_, Extensions> { self.extensions.borrow_mut() } diff --git a/actix-http/src/payload.rs b/actix-http/src/payload.rs index b3ec04d11..9f7f2a31f 100644 --- a/actix-http/src/payload.rs +++ b/actix-http/src/payload.rs @@ -56,7 +56,10 @@ where type Item = Result; #[inline] - fn poll_next(self: Pin<&mut Self>, cx: &mut Context) -> Poll> { + fn poll_next( + self: Pin<&mut Self>, + cx: &mut Context<'_>, + ) -> Poll> { match self.get_mut() { Payload::None => Poll::Ready(None), Payload::H1(ref mut pl) => pl.readany(cx), diff --git a/actix-http/src/request.rs b/actix-http/src/request.rs index 371e2ccd8..64e302441 100644 --- a/actix-http/src/request.rs +++ b/actix-http/src/request.rs @@ -25,13 +25,13 @@ impl

HttpMessage for Request

{ /// Request extensions #[inline] - fn extensions(&self) -> Ref { + fn extensions(&self) -> Ref<'_, Extensions> { self.head.extensions() } /// Mutable reference to a the request's extensions #[inline] - fn extensions_mut(&self) -> RefMut { + fn extensions_mut(&self) -> RefMut<'_, Extensions> { self.head.extensions_mut() } @@ -165,7 +165,7 @@ impl

Request

{ } impl

fmt::Debug for Request

{ - fn fmt(&self, f: &mut fmt::Formatter) -> fmt::Result { + fn fmt(&self, f: &mut fmt::Formatter<'_>) -> fmt::Result { writeln!( f, "\nRequest {:?} {}:{}", diff --git a/actix-http/src/response.rs b/actix-http/src/response.rs index e7f145d39..eee0abc73 100644 --- a/actix-http/src/response.rs +++ b/actix-http/src/response.rs @@ -130,7 +130,7 @@ impl Response { /// Get an iterator for the cookies set by this response #[inline] - pub fn cookies(&self) -> CookieIter { + pub fn cookies(&self) -> CookieIter<'_> { CookieIter { iter: self.head.headers.get_all(header::SET_COOKIE), } @@ -138,7 +138,7 @@ impl Response { /// Add a cookie to this response #[inline] - pub fn add_cookie(&mut self, cookie: &Cookie) -> Result<(), HttpError> { + pub fn add_cookie(&mut self, cookie: &Cookie<'_>) -> Result<(), HttpError> { let h = &mut self.head.headers; HeaderValue::from_str(&cookie.to_string()) .map(|c| { @@ -186,13 +186,13 @@ impl Response { /// Responses extensions #[inline] - pub fn extensions(&self) -> Ref { + pub fn extensions(&self) -> Ref<'_, Extensions> { self.head.extensions.borrow() } /// Mutable reference to a the response's extensions #[inline] - pub fn extensions_mut(&mut self) -> RefMut { + pub fn extensions_mut(&mut self) -> RefMut<'_, Extensions> { self.head.extensions.borrow_mut() } @@ -265,7 +265,7 @@ impl Response { } impl fmt::Debug for Response { - fn fmt(&self, f: &mut fmt::Formatter) -> fmt::Result { + fn fmt(&self, f: &mut fmt::Formatter<'_>) -> fmt::Result { let res = writeln!( f, "\nResponse {:?} {}{}", @@ -285,7 +285,7 @@ impl fmt::Debug for Response { impl Future for Response { type Output = Result; - fn poll(mut self: Pin<&mut Self>, _: &mut Context) -> Poll { + fn poll(mut self: Pin<&mut Self>, _: &mut Context<'_>) -> Poll { Poll::Ready(Ok(Response { head: self.head.take(), body: self.body.take_body(), @@ -588,14 +588,14 @@ impl ResponseBuilder { /// Responses extensions #[inline] - pub fn extensions(&self) -> Ref { + pub fn extensions(&self) -> Ref<'_, Extensions> { let head = self.head.as_ref().expect("cannot reuse response builder"); head.extensions.borrow() } /// Mutable reference to a the response's extensions #[inline] - pub fn extensions_mut(&mut self) -> RefMut { + pub fn extensions_mut(&mut self) -> RefMut<'_, Extensions> { let head = self.head.as_ref().expect("cannot reuse response builder"); head.extensions.borrow_mut() } @@ -765,13 +765,13 @@ impl<'a> From<&'a ResponseHead> for ResponseBuilder { impl Future for ResponseBuilder { type Output = Result; - fn poll(mut self: Pin<&mut Self>, _: &mut Context) -> Poll { + fn poll(mut self: Pin<&mut Self>, _: &mut Context<'_>) -> Poll { Poll::Ready(Ok(self.finish())) } } impl fmt::Debug for ResponseBuilder { - fn fmt(&self, f: &mut fmt::Formatter) -> fmt::Result { + fn fmt(&self, f: &mut fmt::Formatter<'_>) -> fmt::Result { let head = self.head.as_ref().unwrap(); let res = writeln!( diff --git a/actix-http/src/service.rs b/actix-http/src/service.rs index 3624060bf..cb7e541ee 100644 --- a/actix-http/src/service.rs +++ b/actix-http/src/service.rs @@ -403,7 +403,7 @@ where type Output = Result, ()>; - fn poll(mut self: Pin<&mut Self>, cx: &mut Context) -> Poll { + fn poll(mut self: Pin<&mut Self>, cx: &mut Context<'_>) -> Poll { let mut this = self.as_mut().project(); if let Some(fut) = this.fut_ex.as_pin_mut() { @@ -499,7 +499,7 @@ where type Error = DispatchError; type Future = HttpServiceHandlerResponse; - fn poll_ready(&mut self, cx: &mut Context) -> Poll> { + fn poll_ready(&mut self, cx: &mut Context<'_>) -> Poll> { let ready = self .expect .poll_ready(cx) @@ -619,7 +619,7 @@ where { type Output = Result<(), DispatchError>; - fn poll(self: Pin<&mut Self>, cx: &mut Context) -> Poll { + fn poll(self: Pin<&mut Self>, cx: &mut Context<'_>) -> Poll { self.project().state.poll(cx) } } @@ -639,7 +639,7 @@ where #[project] fn poll( mut self: Pin<&mut Self>, - cx: &mut Context, + cx: &mut Context<'_>, ) -> Poll> { #[project] match self.as_mut().project() { diff --git a/actix-http/src/ws/mask.rs b/actix-http/src/ws/mask.rs index 9f7304039..7eb5d148f 100644 --- a/actix-http/src/ws/mask.rs +++ b/actix-http/src/ws/mask.rs @@ -51,7 +51,7 @@ pub(crate) fn apply_mask(buf: &mut [u8], mask_u32: u32) { // inefficient, it could be done better. The compiler does not understand that // a `ShortSlice` must be smaller than a u64. #[allow(clippy::needless_pass_by_value)] -fn xor_short(buf: ShortSlice, mask: u64) { +fn xor_short(buf: ShortSlice<'_>, mask: u64) { // Unsafe: we know that a `ShortSlice` fits in a u64 unsafe { let (ptr, len) = (buf.0.as_mut_ptr(), buf.0.len()); @@ -77,7 +77,7 @@ unsafe fn cast_slice(buf: &mut [u8]) -> &mut [u64] { #[inline] // Splits a slice into three parts: an unaligned short head and tail, plus an aligned // u64 mid section. -fn align_buf(buf: &mut [u8]) -> (ShortSlice, &mut [u64], ShortSlice) { +fn align_buf(buf: &mut [u8]) -> (ShortSlice<'_>, &mut [u64], ShortSlice<'_>) { let start_ptr = buf.as_ptr() as usize; let end_ptr = start_ptr + buf.len(); diff --git a/actix-http/src/ws/proto.rs b/actix-http/src/ws/proto.rs index e14651a56..df928cdbb 100644 --- a/actix-http/src/ws/proto.rs +++ b/actix-http/src/ws/proto.rs @@ -24,7 +24,7 @@ pub enum OpCode { } impl fmt::Display for OpCode { - fn fmt(&self, f: &mut fmt::Formatter) -> fmt::Result { + fn fmt(&self, f: &mut fmt::Formatter<'_>) -> fmt::Result { match *self { Continue => write!(f, "CONTINUE"), Text => write!(f, "TEXT"), diff --git a/actix-http/src/ws/transport.rs b/actix-http/src/ws/transport.rs index 58ba3160f..101e8f65d 100644 --- a/actix-http/src/ws/transport.rs +++ b/actix-http/src/ws/transport.rs @@ -45,7 +45,7 @@ where { type Output = Result<(), FramedTransportError>; - fn poll(mut self: Pin<&mut Self>, cx: &mut Context) -> Poll { + fn poll(mut self: Pin<&mut Self>, cx: &mut Context<'_>) -> Poll { Pin::new(&mut self.inner).poll(cx) } } diff --git a/src/app_service.rs b/src/app_service.rs index 6a91fa079..b6e4388a1 100644 --- a/src/app_service.rs +++ b/src/app_service.rs @@ -154,7 +154,7 @@ where { type Output = Result, ()>; - fn poll(self: Pin<&mut Self>, cx: &mut Context) -> Poll { + fn poll(self: Pin<&mut Self>, cx: &mut Context<'_>) -> Poll { 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> { + fn poll_ready(&mut self, cx: &mut Context<'_>) -> Poll> { self.service.poll_ready(cx) } @@ -310,7 +310,7 @@ enum CreateAppRoutingItem { impl Future for AppRoutingFactoryResponse { type Output = Result; - fn poll(mut self: Pin<&mut Self>, cx: &mut Context) -> Poll { + fn poll(mut self: Pin<&mut Self>, cx: &mut Context<'_>) -> Poll { 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> { + fn poll_ready(&mut self, _: &mut Context<'_>) -> Poll> { if self.ready.is_none() { Poll::Ready(Ok(())) } else { diff --git a/src/extract.rs b/src/extract.rs index d43402c73..bc3027c1a 100644 --- a/src/extract.rs +++ b/src/extract.rs @@ -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 { + fn poll(self: Pin<&mut Self>, cx: &mut Context<'_>) -> Poll { let this = self.project(); let mut ready = true; diff --git a/src/handler.rs b/src/handler.rs index d1b070d88..33cd2408d 100644 --- a/src/handler.rs +++ b/src/handler.rs @@ -85,7 +85,7 @@ where type Error = Infallible; type Future = HandlerServiceResponse; - fn poll_ready(&mut self, _: &mut Context) -> Poll> { + fn poll_ready(&mut self, _: &mut Context<'_>) -> Poll> { Poll::Ready(Ok(())) } @@ -119,7 +119,7 @@ where { type Output = Result; - fn poll(mut self: Pin<&mut Self>, cx: &mut Context) -> Poll { + fn poll(mut self: Pin<&mut Self>, cx: &mut Context<'_>) -> Poll { 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; - fn poll_ready(&mut self, _: &mut Context) -> Poll> { + fn poll_ready(&mut self, _: &mut Context<'_>) -> Poll> { Poll::Ready(Ok(())) } @@ -240,7 +240,7 @@ where { type Output = Result; - fn poll(mut self: Pin<&mut Self>, cx: &mut Context) -> Poll { + fn poll(mut self: Pin<&mut Self>, cx: &mut Context<'_>) -> Poll { let this = self.as_mut().project(); if let Some(fut) = this.fut_s.as_pin_mut() { diff --git a/src/lib.rs b/src/lib.rs index 04149fbfd..1c5698f1d 100644 --- a/src/lib.rs +++ b/src/lib.rs @@ -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. //! diff --git a/src/middleware/compress.rs b/src/middleware/compress.rs index a697deaec..9551ac1e0 100644 --- a/src/middleware/compress.rs +++ b/src/middleware/compress.rs @@ -106,7 +106,7 @@ where type Error = Error; type Future = CompressResponse; - fn poll_ready(&mut self, cx: &mut Context) -> Poll> { + fn poll_ready(&mut self, cx: &mut Context<'_>) -> Poll> { self.service.poll_ready(cx) } @@ -150,7 +150,7 @@ where { type Output = Result>, Error>; - fn poll(self: Pin<&mut Self>, cx: &mut Context) -> Poll { + fn poll(self: Pin<&mut Self>, cx: &mut Context<'_>) -> Poll { let this = self.project(); match futures::ready!(this.fut.poll(cx)) { diff --git a/src/middleware/condition.rs b/src/middleware/condition.rs index 2ede81783..68d06837e 100644 --- a/src/middleware/condition.rs +++ b/src/middleware/condition.rs @@ -76,7 +76,7 @@ where type Error = E::Error; type Future = Either; - fn poll_ready(&mut self, cx: &mut Context) -> Poll> { + fn poll_ready(&mut self, cx: &mut Context<'_>) -> Poll> { use ConditionMiddleware::*; match self { Enable(service) => service.poll_ready(cx), diff --git a/src/middleware/defaultheaders.rs b/src/middleware/defaultheaders.rs index 14d035ab8..464be1ace 100644 --- a/src/middleware/defaultheaders.rs +++ b/src/middleware/defaultheaders.rs @@ -124,7 +124,7 @@ where type Error = Error; type Future = LocalBoxFuture<'static, Result>; - fn poll_ready(&mut self, cx: &mut Context) -> Poll> { + fn poll_ready(&mut self, cx: &mut Context<'_>) -> Poll> { self.service.poll_ready(cx) } diff --git a/src/middleware/errhandlers.rs b/src/middleware/errhandlers.rs index 7a8684936..ed1e4c999 100644 --- a/src/middleware/errhandlers.rs +++ b/src/middleware/errhandlers.rs @@ -119,7 +119,7 @@ where type Error = Error; type Future = LocalBoxFuture<'static, Result>; - fn poll_ready(&mut self, cx: &mut Context) -> Poll> { + fn poll_ready(&mut self, cx: &mut Context<'_>) -> Poll> { self.service.poll_ready(cx) } diff --git a/src/middleware/logger.rs b/src/middleware/logger.rs index 60c10b207..97fa7463f 100644 --- a/src/middleware/logger.rs +++ b/src/middleware/logger.rs @@ -154,7 +154,7 @@ where type Error = Error; type Future = LoggerResponse; - fn poll_ready(&mut self, cx: &mut Context) -> Poll> { + fn poll_ready(&mut self, cx: &mut Context<'_>) -> Poll> { self.service.poll_ready(cx) } @@ -204,7 +204,7 @@ where { type Output = Result>, Error>; - fn poll(self: Pin<&mut Self>, cx: &mut Context) -> Poll { + fn poll(self: Pin<&mut Self>, cx: &mut Context<'_>) -> Poll { let this = self.project(); let res = match futures::ready!(this.fut.poll(cx)) { @@ -248,7 +248,7 @@ pub struct StreamLog { impl Drop for StreamLog { 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 MessageBody for StreamLog { self.body.size() } - fn poll_next(&mut self, cx: &mut Context) -> Poll>> { + fn poll_next(&mut self, cx: &mut Context<'_>) -> Poll>> { 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)?; } diff --git a/src/middleware/normalize.rs b/src/middleware/normalize.rs index 6bff068bc..f6b834bfe 100644 --- a/src/middleware/normalize.rs +++ b/src/middleware/normalize.rs @@ -68,7 +68,7 @@ where type Error = Error; type Future = S::Future; - fn poll_ready(&mut self, cx: &mut Context) -> Poll> { + fn poll_ready(&mut self, cx: &mut Context<'_>) -> Poll> { 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); diff --git a/src/request.rs b/src/request.rs index 84f0503c0..46b8fe387 100644 --- a/src/request.rs +++ b/src/request.rs @@ -125,13 +125,13 @@ impl HttpRequest { /// Request extensions #[inline] - pub fn extensions(&self) -> Ref { + pub fn extensions(&self) -> Ref<'_, Extensions> { self.head().extensions() } /// Mutable reference to a the request's extensions #[inline] - pub fn extensions_mut(&self) -> RefMut { + 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 { + 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 { + fn extensions(&self) -> Ref<'_, Extensions> { self.0.head.extensions() } /// Mutable reference to a the request's extensions #[inline] - fn extensions_mut(&self) -> RefMut { + 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 {:?} {}:{}", diff --git a/src/resource.rs b/src/resource.rs index 7ee0506a3..41d663d3d 100644 --- a/src/resource.rs +++ b/src/resource.rs @@ -470,7 +470,7 @@ pub struct CreateResourceService { impl Future for CreateResourceService { type Output = Result; - fn poll(mut self: Pin<&mut Self>, cx: &mut Context) -> Poll { + fn poll(mut self: Pin<&mut Self>, cx: &mut Context<'_>) -> Poll { let mut done = true; if let Some(ref mut fut) = self.default_fut { @@ -530,7 +530,7 @@ impl Service for ResourceService { LocalBoxFuture<'static, Result>, >; - fn poll_ready(&mut self, _: &mut Context) -> Poll> { + fn poll_ready(&mut self, _: &mut Context<'_>) -> Poll> { Poll::Ready(Ok(())) } diff --git a/src/responder.rs b/src/responder.rs index 48eae09b6..7189eecf1 100644 --- a/src/responder.rs +++ b/src/responder.rs @@ -313,7 +313,7 @@ pub struct CustomResponderFut { impl Future for CustomResponderFut { type Output = Result; - fn poll(self: Pin<&mut Self>, cx: &mut Context) -> Poll { + fn poll(self: Pin<&mut Self>, cx: &mut Context<'_>) -> Poll { let this = self.project(); let mut res = match ready!(this.fut.poll(cx)) { @@ -397,7 +397,7 @@ where type Output = Result; #[project] - fn poll(self: Pin<&mut Self>, cx: &mut Context) -> Poll { + fn poll(self: Pin<&mut Self>, cx: &mut Context<'_>) -> Poll { #[project] match self.project() { EitherResponder::A(fut) => { @@ -446,7 +446,7 @@ where { type Output = Result; - fn poll(self: Pin<&mut Self>, cx: &mut Context) -> Poll { + fn poll(self: Pin<&mut Self>, cx: &mut Context<'_>) -> Poll { Poll::Ready(ready!(self.project().fut.poll(cx)).map_err(|e| e.into())) } } diff --git a/src/route.rs b/src/route.rs index 2c643099b..f7e391746 100644 --- a/src/route.rs +++ b/src/route.rs @@ -92,7 +92,7 @@ pub struct CreateRouteService { impl Future for CreateRouteService { type Output = Result; - fn poll(self: Pin<&mut Self>, cx: &mut Context) -> Poll { + fn poll(self: Pin<&mut Self>, cx: &mut Context<'_>) -> Poll { 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>; - fn poll_ready(&mut self, cx: &mut Context) -> Poll> { + fn poll_ready(&mut self, cx: &mut Context<'_>) -> Poll> { self.service.poll_ready(cx) } @@ -313,7 +313,7 @@ where type Error = Error; type Future = LocalBoxFuture<'static, Result>; - fn poll_ready(&mut self, cx: &mut Context) -> Poll> { + fn poll_ready(&mut self, cx: &mut Context<'_>) -> Poll> { self.service.poll_ready(cx).map_err(|(e, _)| e) } diff --git a/src/scope.rs b/src/scope.rs index d6b88577b..26ace6892 100644 --- a/src/scope.rs +++ b/src/scope.rs @@ -534,7 +534,7 @@ enum CreateScopeServiceItem { impl Future for ScopeFactoryResponse { type Output = Result; - fn poll(mut self: Pin<&mut Self>, cx: &mut Context) -> Poll { + fn poll(mut self: Pin<&mut Self>, cx: &mut Context<'_>) -> Poll { 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>>; - fn poll_ready(&mut self, _: &mut Context) -> Poll> { + fn poll_ready(&mut self, _: &mut Context<'_>) -> Poll> { Poll::Ready(Ok(())) } diff --git a/src/server.rs b/src/server.rs index 03abad160..a4569ce3d 100644 --- a/src/server.rs +++ b/src/server.rs @@ -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; diff --git a/src/service.rs b/src/service.rs index b392e6e8b..b58fb5b4e 100644 --- a/src/service.rs +++ b/src/service.rs @@ -181,7 +181,7 @@ impl ServiceRequest { /// Get *ConnectionInfo* for the current request. #[inline] - pub fn connection_info(&self) -> Ref { + 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 { + fn extensions(&self) -> Ref<'_, Extensions> { self.0.extensions() } /// Mutable reference to a the request's extensions #[inline] - fn extensions_mut(&self) -> RefMut { + 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 Into> for ServiceResponse { } impl fmt::Debug for ServiceResponse { - fn fmt(&self, f: &mut fmt::Formatter) -> fmt::Result { + fn fmt(&self, f: &mut fmt::Formatter<'_>) -> fmt::Result { let res = writeln!( f, "\nServiceResponse {:?} {}{}", diff --git a/src/test.rs b/src/test.rs index 5e50f24e1..419ea2d36 100644 --- a/src/test.rs +++ b/src/test.rs @@ -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 } diff --git a/src/types/form.rs b/src/types/form.rs index e1bd52375..977f88d0b 100644 --- a/src/types/form.rs +++ b/src/types/form.rs @@ -141,13 +141,13 @@ where } impl fmt::Debug for Form { - fn fmt(&self, f: &mut fmt::Formatter) -> fmt::Result { + fn fmt(&self, f: &mut fmt::Formatter<'_>) -> fmt::Result { self.0.fmt(f) } } impl fmt::Display for Form { - 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; - fn poll(mut self: Pin<&mut Self>, cx: &mut Context) -> Poll { + fn poll(mut self: Pin<&mut Self>, cx: &mut Context<'_>) -> Poll { if let Some(ref mut fut) = self.fut { return Pin::new(fut).poll(cx); } diff --git a/src/types/json.rs b/src/types/json.rs index 028092d1a..8112d04f2 100644 --- a/src/types/json.rs +++ b/src/types/json.rs @@ -106,7 +106,7 @@ impl fmt::Debug for Json 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 fmt::Display for Json 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; - fn poll(mut self: Pin<&mut Self>, cx: &mut Context) -> Poll { + fn poll(mut self: Pin<&mut Self>, cx: &mut Context<'_>) -> Poll { if let Some(ref mut fut) = self.fut { return Pin::new(fut).poll(cx); } diff --git a/src/types/path.rs b/src/types/path.rs index 404759300..d1a5f1fb9 100644 --- a/src/types/path.rs +++ b/src/types/path.rs @@ -97,13 +97,13 @@ impl From for Path { } impl fmt::Debug for Path { - fn fmt(&self, f: &mut fmt::Formatter) -> fmt::Result { + fn fmt(&self, f: &mut fmt::Formatter<'_>) -> fmt::Result { self.inner.fmt(f) } } impl fmt::Display for Path { - fn fmt(&self, f: &mut fmt::Formatter) -> fmt::Result { + fn fmt(&self, f: &mut fmt::Formatter<'_>) -> fmt::Result { self.inner.fmt(f) } } diff --git a/src/types/payload.rs b/src/types/payload.rs index 2969e385a..8e52a3b6c 100644 --- a/src/types/payload.rs +++ b/src/types/payload.rs @@ -59,7 +59,7 @@ impl Stream for Payload { #[inline] fn poll_next( mut self: Pin<&mut Self>, - cx: &mut Context, + cx: &mut Context<'_>, ) -> Poll> { Pin::new(&mut self.0).poll_next(cx) } @@ -351,7 +351,7 @@ impl HttpMessageBody { impl Future for HttpMessageBody { type Output = Result; - fn poll(mut self: Pin<&mut Self>, cx: &mut Context) -> Poll { + fn poll(mut self: Pin<&mut Self>, cx: &mut Context<'_>) -> Poll { if let Some(ref mut fut) = self.fut { return Pin::new(fut).poll(cx); } diff --git a/src/types/query.rs b/src/types/query.rs index b1f4572fa..9d62f31c6 100644 --- a/src/types/query.rs +++ b/src/types/query.rs @@ -84,13 +84,13 @@ impl ops::DerefMut for Query { } impl fmt::Debug for Query { - fn fmt(&self, f: &mut fmt::Formatter) -> fmt::Result { + fn fmt(&self, f: &mut fmt::Formatter<'_>) -> fmt::Result { self.0.fmt(f) } } impl fmt::Display for Query { - fn fmt(&self, f: &mut fmt::Formatter) -> fmt::Result { + fn fmt(&self, f: &mut fmt::Formatter<'_>) -> fmt::Result { self.0.fmt(f) } } diff --git a/src/types/readlines.rs b/src/types/readlines.rs index 123f8102b..82853381b 100644 --- a/src/types/readlines.rs +++ b/src/types/readlines.rs @@ -68,7 +68,10 @@ where { 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> { let this = self.get_mut(); if let Some(err) = this.err.take() {