Skip to content

Commit

Permalink
nightly clippy warnings
Browse files Browse the repository at this point in the history
  • Loading branch information
fafhrd91 committed Jul 17, 2019
1 parent 4092c7f commit 2a2d7f5
Show file tree
Hide file tree
Showing 34 changed files with 104 additions and 99 deletions.
4 changes: 2 additions & 2 deletions Cargo.toml
Original file line number Diff line number Diff line change
Expand Up @@ -75,7 +75,7 @@ actix-utils = "0.4.4"
actix-router = "0.1.5"
actix-rt = "0.2.4"
actix-web-codegen = "0.1.2"
actix-http = "0.2.5"
actix-http = "0.2.6"
actix-server = "0.5.1"
actix-server-config = "0.1.1"
actix-threadpool = "0.1.1"
Expand All @@ -89,7 +89,7 @@ hashbrown = "0.5.0"
log = "0.4"
mime = "0.3"
net2 = "0.2.33"
parking_lot = "0.8"
parking_lot = "0.9"
regex = "1.0"
serde = { version = "1.0", features=["derive"] }
serde_json = "1.0"
Expand Down
6 changes: 3 additions & 3 deletions actix-cors/src/lib.rs
Original file line number Diff line number Diff line change
Expand Up @@ -587,10 +587,10 @@ impl Inner {
}
Err(CorsError::BadOrigin)
} else {
return match self.origins {
match self.origins {
AllOrSome::All => Ok(()),
_ => Err(CorsError::MissingOrigin),
};
}
}
}

Expand Down Expand Up @@ -665,7 +665,7 @@ impl Inner {
}
Err(CorsError::BadRequestHeaders)
} else {
return Ok(());
Ok(())
}
}
}
Expand Down
16 changes: 8 additions & 8 deletions actix-files/src/lib.rs
Original file line number Diff line number Diff line change
Expand Up @@ -107,7 +107,7 @@ impl Stream for ChunkedReadFile {
}

type DirectoryRenderer =
Fn(&Directory, &HttpRequest) -> Result<ServiceResponse, io::Error>;
dyn Fn(&Directory, &HttpRequest) -> Result<ServiceResponse, io::Error>;

/// A directory; responds with the generated directory listing.
#[derive(Debug)]
Expand Down Expand Up @@ -211,7 +211,7 @@ fn directory_listing(
))
}

type MimeOverride = Fn(&mime::Name) -> DispositionType;
type MimeOverride = dyn Fn(&mime::Name) -> DispositionType;

/// Static files handling
///
Expand Down Expand Up @@ -475,15 +475,15 @@ impl Service for FilesService {
Err(e) => ServiceResponse::from_err(e, req),
}))
}
Err(e) => return self.handle_err(e, req),
Err(e) => self.handle_err(e, req),
}
} else if self.show_index {
let dir = Directory::new(self.directory.clone(), path);
let (req, _) = req.into_parts();
let x = (self.renderer)(&dir, &req);
match x {
Ok(resp) => Either::A(ok(resp)),
Err(e) => return Either::A(ok(ServiceResponse::from_err(e, req))),
Err(e) => Either::A(ok(ServiceResponse::from_err(e, req))),
}
} else {
Either::A(ok(ServiceResponse::from_err(
Expand Down Expand Up @@ -857,7 +857,7 @@ mod tests {

#[test]
fn test_named_file_content_length_headers() {
use actix_web::body::{MessageBody, ResponseBody};
// use actix_web::body::{MessageBody, ResponseBody};

let mut srv = test::init_service(
App::new().service(Files::new("test", ".").index_file("tests/test.binary")),
Expand All @@ -868,7 +868,7 @@ mod tests {
.uri("/t%65st/tests/test.binary")
.header(header::RANGE, "bytes=10-20")
.to_request();
let response = test::call_service(&mut srv, request);
let _response = test::call_service(&mut srv, request);

// let contentlength = response
// .headers()
Expand All @@ -891,7 +891,7 @@ mod tests {
.uri("/t%65st/tests/test.binary")
// .no_default_headers()
.to_request();
let response = test::call_service(&mut srv, request);
let _response = test::call_service(&mut srv, request);

// let contentlength = response
// .headers()
Expand Down Expand Up @@ -939,7 +939,7 @@ mod tests {
.method(Method::HEAD)
.uri("/t%65st/tests/test.binary")
.to_request();
let response = test::call_service(&mut srv, request);
let _response = test::call_service(&mut srv, request);

// TODO: fix check
// let contentlength = response
Expand Down
2 changes: 1 addition & 1 deletion actix-files/src/range.rs
Original file line number Diff line number Diff line change
Expand Up @@ -5,7 +5,7 @@ pub struct HttpRange {
pub length: u64,
}

static PREFIX: &'static str = "bytes=";
static PREFIX: &str = "bytes=";
const PREFIX_LEN: usize = 6;

impl HttpRange {
Expand Down
4 changes: 2 additions & 2 deletions actix-framed/src/helpers.rs
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,7 @@ use actix_service::{NewService, Service};
use futures::{Future, Poll};

pub(crate) type BoxedHttpService<Req> = Box<
Service<
dyn Service<
Request = Req,
Response = (),
Error = Error,
Expand All @@ -12,7 +12,7 @@ pub(crate) type BoxedHttpService<Req> = Box<
>;

pub(crate) type BoxedHttpNewService<Req> = Box<
NewService<
dyn NewService<
Config = (),
Request = Req,
Response = (),
Expand Down
2 changes: 1 addition & 1 deletion actix-http/src/builder.rs
Original file line number Diff line number Diff line change
Expand Up @@ -26,7 +26,7 @@ pub struct HttpServiceBuilder<T, S, X = ExpectHandler, U = UpgradeHandler<T>> {
client_disconnect: u64,
expect: X,
upgrade: Option<U>,
on_connect: Option<Rc<Fn(&T) -> Box<dyn DataFactory>>>,
on_connect: Option<Rc<dyn Fn(&T) -> Box<dyn DataFactory>>>,
_t: PhantomData<(T, S)>,
}

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 @@ -130,7 +130,7 @@ where

type TunnelFuture = Either<
Box<
Future<
dyn Future<
Item = (ResponseHead, Framed<Self::Io, ClientCodec>),
Error = SendRequestError,
>,
Expand Down Expand Up @@ -192,7 +192,7 @@ where
}

type TunnelFuture = Box<
Future<
dyn Future<
Item = (ResponseHead, Framed<Self::Io, ClientCodec>),
Error = SendRequestError,
>,
Expand Down
2 changes: 1 addition & 1 deletion actix-http/src/cookie/secure/key.rs
Original file line number Diff line number Diff line change
Expand Up @@ -6,7 +6,7 @@ use ring::rand::{SecureRandom, SystemRandom};
use super::private::KEY_LEN as PRIVATE_KEY_LEN;
use super::signed::KEY_LEN as SIGNED_KEY_LEN;

static HKDF_DIGEST: &'static Algorithm = &SHA256;
static HKDF_DIGEST: &Algorithm = &SHA256;
const KEYS_INFO: &str = "COOKIE;SIGNED:HMAC-SHA256;PRIVATE:AEAD-AES-256-GCM";

/// A cryptographic master key for use with `Signed` and/or `Private` jars.
Expand Down
2 changes: 1 addition & 1 deletion 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
2 changes: 1 addition & 1 deletion actix-http/src/cookie/secure/signed.rs
Original file line number Diff line number Diff line change
Expand Up @@ -6,7 +6,7 @@ use crate::cookie::{Cookie, CookieJar};

// Keep these in sync, and keep the key len synced with the `signed` docs as
// well as the `KEYS_INFO` const in secure::Key.
static HMAC_DIGEST: &'static Algorithm = &SHA256;
static HMAC_DIGEST: &Algorithm = &SHA256;
const BASE64_DIGEST_LEN: usize = 44;
pub const KEY_LEN: usize = 32;

Expand Down
4 changes: 2 additions & 2 deletions actix-http/src/error.rs
Original file line number Diff line number Diff line change
Expand Up @@ -43,12 +43,12 @@ pub type Result<T, E = Error> = result::Result<T, E>;
/// if you have access to an actix `Error` you can always get a
/// `ResponseError` reference from it.
pub struct Error {
cause: Box<ResponseError>,
cause: Box<dyn ResponseError>,
}

impl Error {
/// Returns the reference to the underlying `ResponseError`.
pub fn as_response_error(&self) -> &ResponseError {
pub fn as_response_error(&self) -> &dyn ResponseError {
self.cause.as_ref()
}
}
Expand Down
8 changes: 4 additions & 4 deletions actix-http/src/extensions.rs
Original file line number Diff line number Diff line change
Expand Up @@ -6,7 +6,7 @@ use hashbrown::HashMap;
#[derive(Default)]
/// A type map of request extensions.
pub struct Extensions {
map: HashMap<TypeId, Box<Any>>,
map: HashMap<TypeId, Box<dyn Any>>,
}

impl Extensions {
Expand Down Expand Up @@ -35,22 +35,22 @@ impl Extensions {
pub fn get<T: 'static>(&self) -> Option<&T> {
self.map
.get(&TypeId::of::<T>())
.and_then(|boxed| (&**boxed as &(Any + 'static)).downcast_ref())
.and_then(|boxed| (&**boxed as &(dyn Any + 'static)).downcast_ref())
}

/// Get a mutable reference to a type previously inserted on this `Extensions`.
pub fn get_mut<T: 'static>(&mut self) -> Option<&mut T> {
self.map
.get_mut(&TypeId::of::<T>())
.and_then(|boxed| (&mut **boxed as &mut (Any + 'static)).downcast_mut())
.and_then(|boxed| (&mut **boxed as &mut (dyn Any + 'static)).downcast_mut())
}

/// Remove a type from this `Extensions`.
///
/// If a extension of this type existed, it will be returned.
pub fn remove<T: 'static>(&mut self) -> Option<T> {
self.map.remove(&TypeId::of::<T>()).and_then(|boxed| {
(boxed as Box<Any + 'static>)
(boxed as Box<dyn Any + 'static>)
.downcast()
.ok()
.map(|boxed| *boxed)
Expand Down
6 changes: 3 additions & 3 deletions actix-http/src/h1/decoder.rs
Original file line number Diff line number Diff line change
Expand Up @@ -502,15 +502,15 @@ impl ChunkedState {
fn read_size(rdr: &mut BytesMut, size: &mut u64) -> Poll<ChunkedState, io::Error> {
let radix = 16;
match byte!(rdr) {
b @ b'0'...b'9' => {
b @ b'0'..=b'9' => {
*size *= radix;
*size += u64::from(b - b'0');
}
b @ b'a'...b'f' => {
b @ b'a'..=b'f' => {
*size *= radix;
*size += u64::from(b + 10 - b'a');
}
b @ b'A'...b'F' => {
b @ b'A'..=b'F' => {
*size *= radix;
*size += u64::from(b + 10 - b'A');
}
Expand Down
10 changes: 5 additions & 5 deletions actix-http/src/h1/service.rs
Original file line number Diff line number Diff line change
Expand Up @@ -26,7 +26,7 @@ pub struct H1Service<T, P, S, B, X = ExpectHandler, U = UpgradeHandler<T>> {
cfg: ServiceConfig,
expect: X,
upgrade: Option<U>,
on_connect: Option<Rc<Fn(&T) -> Box<dyn DataFactory>>>,
on_connect: Option<Rc<dyn Fn(&T) -> Box<dyn DataFactory>>>,
_t: PhantomData<(T, P, B)>,
}

Expand Down Expand Up @@ -108,7 +108,7 @@ where
/// Set on connect callback.
pub(crate) fn on_connect(
mut self,
f: Option<Rc<Fn(&T) -> Box<dyn DataFactory>>>,
f: Option<Rc<dyn Fn(&T) -> Box<dyn DataFactory>>>,
) -> Self {
self.on_connect = f;
self
Expand Down Expand Up @@ -174,7 +174,7 @@ where
fut_upg: Option<U::Future>,
expect: Option<X::Service>,
upgrade: Option<U::Service>,
on_connect: Option<Rc<Fn(&T) -> Box<dyn DataFactory>>>,
on_connect: Option<Rc<dyn Fn(&T) -> Box<dyn DataFactory>>>,
cfg: Option<ServiceConfig>,
_t: PhantomData<(T, P, B)>,
}
Expand Down Expand Up @@ -233,7 +233,7 @@ pub struct H1ServiceHandler<T, P, S, B, X, U> {
srv: CloneableService<S>,
expect: CloneableService<X>,
upgrade: Option<CloneableService<U>>,
on_connect: Option<Rc<Fn(&T) -> Box<dyn DataFactory>>>,
on_connect: Option<Rc<dyn Fn(&T) -> Box<dyn DataFactory>>>,
cfg: ServiceConfig,
_t: PhantomData<(T, P, B)>,
}
Expand All @@ -254,7 +254,7 @@ where
srv: S,
expect: X,
upgrade: Option<U>,
on_connect: Option<Rc<Fn(&T) -> Box<dyn DataFactory>>>,
on_connect: Option<Rc<dyn Fn(&T) -> Box<dyn DataFactory>>>,
) -> H1ServiceHandler<T, P, S, B, X, U> {
H1ServiceHandler {
srv: CloneableService::new(srv),
Expand Down
10 changes: 5 additions & 5 deletions actix-http/src/h2/service.rs
Original file line number Diff line number Diff line change
Expand Up @@ -27,7 +27,7 @@ use super::dispatcher::Dispatcher;
pub struct H2Service<T, P, S, B> {
srv: S,
cfg: ServiceConfig,
on_connect: Option<rc::Rc<Fn(&T) -> Box<dyn DataFactory>>>,
on_connect: Option<rc::Rc<dyn Fn(&T) -> Box<dyn DataFactory>>>,
_t: PhantomData<(T, P, B)>,
}

Expand Down Expand Up @@ -64,7 +64,7 @@ where
/// Set on connect callback.
pub(crate) fn on_connect(
mut self,
f: Option<rc::Rc<Fn(&T) -> Box<dyn DataFactory>>>,
f: Option<rc::Rc<dyn Fn(&T) -> Box<dyn DataFactory>>>,
) -> Self {
self.on_connect = f;
self
Expand Down Expand Up @@ -102,7 +102,7 @@ where
pub struct H2ServiceResponse<T, P, S: NewService, B> {
fut: <S::Future as IntoFuture>::Future,
cfg: Option<ServiceConfig>,
on_connect: Option<rc::Rc<Fn(&T) -> Box<dyn DataFactory>>>,
on_connect: Option<rc::Rc<dyn Fn(&T) -> Box<dyn DataFactory>>>,
_t: PhantomData<(T, P, B)>,
}

Expand Down Expand Up @@ -132,7 +132,7 @@ where
pub struct H2ServiceHandler<T, P, S, B> {
srv: CloneableService<S>,
cfg: ServiceConfig,
on_connect: Option<rc::Rc<Fn(&T) -> Box<dyn DataFactory>>>,
on_connect: Option<rc::Rc<dyn Fn(&T) -> Box<dyn DataFactory>>>,
_t: PhantomData<(T, P, B)>,
}

Expand All @@ -146,7 +146,7 @@ where
{
fn new(
cfg: ServiceConfig,
on_connect: Option<rc::Rc<Fn(&T) -> Box<dyn DataFactory>>>,
on_connect: Option<rc::Rc<dyn Fn(&T) -> Box<dyn DataFactory>>>,
srv: S,
) -> H2ServiceHandler<T, P, S, B> {
H2ServiceHandler {
Expand Down
10 changes: 5 additions & 5 deletions actix-http/src/service.rs
Original file line number Diff line number Diff line change
Expand Up @@ -26,7 +26,7 @@ pub struct HttpService<T, P, S, B, X = h1::ExpectHandler, U = h1::UpgradeHandler
cfg: ServiceConfig,
expect: X,
upgrade: Option<U>,
on_connect: Option<rc::Rc<Fn(&T) -> Box<dyn DataFactory>>>,
on_connect: Option<rc::Rc<dyn Fn(&T) -> Box<dyn DataFactory>>>,
_t: PhantomData<(T, P, B)>,
}

Expand Down Expand Up @@ -140,7 +140,7 @@ where
/// Set on connect callback.
pub(crate) fn on_connect(
mut self,
f: Option<rc::Rc<Fn(&T) -> Box<dyn DataFactory>>>,
f: Option<rc::Rc<dyn Fn(&T) -> Box<dyn DataFactory>>>,
) -> Self {
self.on_connect = f;
self
Expand Down Expand Up @@ -196,7 +196,7 @@ pub struct HttpServiceResponse<T, P, S: NewService, B, X: NewService, U: NewServ
fut_upg: Option<U::Future>,
expect: Option<X::Service>,
upgrade: Option<U::Service>,
on_connect: Option<rc::Rc<Fn(&T) -> Box<dyn DataFactory>>>,
on_connect: Option<rc::Rc<dyn Fn(&T) -> Box<dyn DataFactory>>>,
cfg: Option<ServiceConfig>,
_t: PhantomData<(T, P, B)>,
}
Expand Down Expand Up @@ -257,7 +257,7 @@ pub struct HttpServiceHandler<T, P, S, B, X, U> {
expect: CloneableService<X>,
upgrade: Option<CloneableService<U>>,
cfg: ServiceConfig,
on_connect: Option<rc::Rc<Fn(&T) -> Box<dyn DataFactory>>>,
on_connect: Option<rc::Rc<dyn Fn(&T) -> Box<dyn DataFactory>>>,
_t: PhantomData<(T, P, B, X)>,
}

Expand All @@ -278,7 +278,7 @@ where
srv: S,
expect: X,
upgrade: Option<U>,
on_connect: Option<rc::Rc<Fn(&T) -> Box<dyn DataFactory>>>,
on_connect: Option<rc::Rc<dyn Fn(&T) -> Box<dyn DataFactory>>>,
) -> HttpServiceHandler<T, P, S, B, X, U> {
HttpServiceHandler {
cfg,
Expand Down
Loading

0 comments on commit 2a2d7f5

Please sign in to comment.