Skip to content

Commit

Permalink
clippy warnings
Browse files Browse the repository at this point in the history
  • Loading branch information
fafhrd91 committed Dec 7, 2019
1 parent 8df33f7 commit 6c9f9ff
Show file tree
Hide file tree
Showing 73 changed files with 222 additions and 207 deletions.
33 changes: 18 additions & 15 deletions actix-http/src/body.rs
Original file line number Diff line number Diff line change
Expand Up @@ -35,15 +35,15 @@ impl BodySize {
pub trait MessageBody {
fn size(&self) -> BodySize;

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>>>;
}

impl MessageBody for () {
fn size(&self) -> BodySize {
BodySize::Empty
}

fn poll_next(&mut self, _: &mut Context) -> Poll<Option<Result<Bytes, Error>>> {
fn poll_next(&mut self, _: &mut Context<'_>) -> Poll<Option<Result<Bytes, Error>>> {
Poll::Ready(None)
}
}
Expand All @@ -53,7 +53,7 @@ impl<T: MessageBody> MessageBody for Box<T> {
self.as_ref().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>>> {
self.as_mut().poll_next(cx)
}
}
Expand Down Expand Up @@ -97,7 +97,7 @@ impl<B: MessageBody> MessageBody for ResponseBody<B> {
}
}

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 {
ResponseBody::Body(ref mut body) => body.poll_next(cx),
ResponseBody::Other(ref mut body) => body.poll_next(cx),
Expand All @@ -109,7 +109,10 @@ impl<B: MessageBody> Stream for ResponseBody<B> {
type Item = Result<Bytes, Error>;

#[project]
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>> {
#[project]
match self.project() {
ResponseBody::Body(ref mut body) => body.poll_next(cx),
Expand Down Expand Up @@ -152,7 +155,7 @@ impl MessageBody for Body {
}
}

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::None => Poll::Ready(None),
Body::Empty => Poll::Ready(None),
Expand Down Expand Up @@ -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"),
Expand Down Expand Up @@ -272,7 +275,7 @@ impl MessageBody for Bytes {
BodySize::Sized(self.len())
}

fn poll_next(&mut self, _: &mut Context) -> Poll<Option<Result<Bytes, Error>>> {
fn poll_next(&mut self, _: &mut Context<'_>) -> Poll<Option<Result<Bytes, Error>>> {
if self.is_empty() {
Poll::Ready(None)
} else {
Expand All @@ -286,7 +289,7 @@ impl MessageBody for BytesMut {
BodySize::Sized(self.len())
}

fn poll_next(&mut self, _: &mut Context) -> Poll<Option<Result<Bytes, Error>>> {
fn poll_next(&mut self, _: &mut Context<'_>) -> Poll<Option<Result<Bytes, Error>>> {
if self.is_empty() {
Poll::Ready(None)
} else {
Expand All @@ -300,7 +303,7 @@ impl MessageBody for &'static str {
BodySize::Sized(self.len())
}

fn poll_next(&mut self, _: &mut Context) -> Poll<Option<Result<Bytes, Error>>> {
fn poll_next(&mut self, _: &mut Context<'_>) -> Poll<Option<Result<Bytes, Error>>> {
if self.is_empty() {
Poll::Ready(None)
} else {
Expand All @@ -316,7 +319,7 @@ impl MessageBody for &'static [u8] {
BodySize::Sized(self.len())
}

fn poll_next(&mut self, _: &mut Context) -> Poll<Option<Result<Bytes, Error>>> {
fn poll_next(&mut self, _: &mut Context<'_>) -> Poll<Option<Result<Bytes, Error>>> {
if self.is_empty() {
Poll::Ready(None)
} else {
Expand All @@ -330,7 +333,7 @@ impl MessageBody for Vec<u8> {
BodySize::Sized(self.len())
}

fn poll_next(&mut self, _: &mut Context) -> Poll<Option<Result<Bytes, Error>>> {
fn poll_next(&mut self, _: &mut Context<'_>) -> Poll<Option<Result<Bytes, Error>>> {
if self.is_empty() {
Poll::Ready(None)
} else {
Expand All @@ -344,7 +347,7 @@ impl MessageBody for String {
BodySize::Sized(self.len())
}

fn poll_next(&mut self, _: &mut Context) -> Poll<Option<Result<Bytes, Error>>> {
fn poll_next(&mut self, _: &mut Context<'_>) -> Poll<Option<Result<Bytes, Error>>> {
if self.is_empty() {
Poll::Ready(None)
} else {
Expand Down Expand Up @@ -386,7 +389,7 @@ where
BodySize::Stream
}

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>>> {
unsafe { Pin::new_unchecked(self) }
.project()
.stream
Expand Down Expand Up @@ -421,7 +424,7 @@ where
BodySize::Sized64(self.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>>> {
unsafe { Pin::new_unchecked(self) }
.project()
.stream
Expand Down
4 changes: 2 additions & 2 deletions actix-http/src/client/connection.rs
Original file line number Diff line number Diff line change
Expand Up @@ -63,7 +63,7 @@ impl<T> fmt::Debug for IoConnection<T>
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"),
Expand Down Expand Up @@ -247,7 +247,7 @@ where
#[project]
fn poll_write(
self: Pin<&mut Self>,
cx: &mut Context,
cx: &mut Context<'_>,
buf: &[u8],
) -> Poll<io::Result<usize>> {
#[project]
Expand Down
14 changes: 7 additions & 7 deletions actix-http/src/client/connector.rs
Original file line number Diff line number Diff line change
Expand Up @@ -62,7 +62,7 @@ trait Io: AsyncRead + AsyncWrite + Unpin {}
impl<T: AsyncRead + AsyncWrite + Unpin> 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<Uri>,
Expand Down Expand Up @@ -378,7 +378,7 @@ mod connect_impl {
Ready<Result<IoConnection<Io>, ConnectError>>,
>;

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.tcp_pool.poll_ready(cx)
}

Expand Down Expand Up @@ -451,7 +451,7 @@ mod connect_impl {
InnerConnectorResponseB<T2, Io1, Io2>,
>;

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.tcp_pool.poll_ready(cx)
}

Expand Down Expand Up @@ -490,10 +490,10 @@ mod connect_impl {
{
type Output = Result<EitherConnection<Io1, Io2>, ConnectError>;

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!(Pin::new(&mut self.get_mut().fut).poll(cx))
.map(|res| EitherConnection::A(res)),
.map(EitherConnection::A),
)
}
}
Expand All @@ -519,10 +519,10 @@ mod connect_impl {
{
type Output = Result<EitherConnection<Io1, Io2>, ConnectError>;

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!(Pin::new(&mut self.get_mut().fut).poll(cx))
.map(|res| EitherConnection::B(res)),
.map(EitherConnection::B),
)
}
}
Expand Down
7 changes: 5 additions & 2 deletions actix-http/src/client/h1proto.rs
Original file line number Diff line number Diff line change
Expand Up @@ -234,7 +234,7 @@ impl<T: AsyncRead + AsyncWrite + Unpin + 'static> AsyncWrite for H1Connection<T>

fn poll_shutdown(
mut self: Pin<&mut Self>,
cx: &mut Context,
cx: &mut Context<'_>,
) -> Poll<Result<(), io::Error>> {
Pin::new(self.io.as_mut().unwrap()).poll_shutdown(cx)
}
Expand All @@ -255,7 +255,10 @@ impl<Io: ConnectionLifetime> PlStream<Io> {
impl<Io: ConnectionLifetime> Stream for PlStream<Io> {
type Item = Result<Bytes, PayloadError>;

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();

match this.framed.as_mut().unwrap().next_item(cx)? {
Expand Down
10 changes: 5 additions & 5 deletions actix-http/src/client/pool.rs
Original file line number Diff line number Diff line change
Expand Up @@ -93,7 +93,7 @@ where
type Error = ConnectError;
type Future = LocalBoxFuture<'static, Result<IoConnection<Io>, ConnectError>>;

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.0.poll_ready(cx)
}

Expand Down Expand Up @@ -308,7 +308,7 @@ where
(rx, token)
}

fn acquire(&mut self, key: &Key, cx: &mut Context) -> Acquire<Io> {
fn acquire(&mut self, key: &Key, cx: &mut Context<'_>) -> Acquire<Io> {
// check limits
if self.limit > 0 && self.acquired >= self.limit {
return Acquire::NotAvailable;
Expand Down Expand Up @@ -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) {
Expand Down Expand Up @@ -438,7 +438,7 @@ where
{
type Output = ();

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 = unsafe { self.get_unchecked_mut() };

let mut inner = this.inner.as_ref().borrow_mut();
Expand Down Expand Up @@ -545,7 +545,7 @@ where
{
type Output = ();

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 = unsafe { self.get_unchecked_mut() };

if let Some(ref mut h2) = this.h2 {
Expand Down
2 changes: 1 addition & 1 deletion actix-http/src/cloneable.rs
Original file line number Diff line number Diff line change
Expand Up @@ -32,7 +32,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>> {
unsafe { &mut *self.0.as_ref().get() }.poll_ready(cx)
}

Expand Down
2 changes: 1 addition & 1 deletion actix-http/src/cookie/draft.rs
Original file line number Diff line number Diff line change
Expand Up @@ -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"),
Expand Down
8 changes: 4 additions & 4 deletions actix-http/src/cookie/jar.rs
Original file line number Diff line number Diff line change
Expand Up @@ -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(),
}
Expand Down Expand Up @@ -343,7 +343,7 @@ impl CookieJar {
/// }
/// }
/// ```
pub fn iter(&self) -> Iter {
pub fn iter(&self) -> Iter<'_> {
Iter {
delta_cookies: self
.delta_cookies
Expand Down Expand Up @@ -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)
}

Expand Down Expand Up @@ -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)
}
}
Expand Down
10 changes: 5 additions & 5 deletions actix-http/src/cookie/mod.rs
Original file line number Diff line number Diff line change
Expand Up @@ -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<str>>) -> &'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(
Expand Down Expand Up @@ -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")?;
}
Expand Down Expand Up @@ -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);
Expand All @@ -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)
}
Expand Down
2 changes: 1 addition & 1 deletion actix-http/src/cookie/parse.rs
Original file line number Diff line number Diff line change
Expand Up @@ -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())
}
}
Expand Down
4 changes: 2 additions & 2 deletions actix-http/src/cookie/secure/private.rs
Original file line number Diff line number Diff line change
Expand Up @@ -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;

Expand Down Expand Up @@ -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);
Expand Down
Loading

0 comments on commit 6c9f9ff

Please sign in to comment.