1
0
Fork 0
mirror of https://github.com/actix/actix-web.git synced 2024-12-22 08:07:18 +00:00

fix clippy warning on nightly (#2088)

* fix clippy warning on nightly
This commit is contained in:
fakeshadow 2021-03-19 04:25:35 -07:00 committed by GitHub
parent 78fcd0237a
commit 351286486c
No known key found for this signature in database
GPG key ID: 4AEE18F83AFDEB23
11 changed files with 30 additions and 52 deletions

View file

@ -1,4 +1,4 @@
use std::{fmt, io, path::PathBuf, rc::Rc, task::Poll};
use std::{fmt, io, path::PathBuf, rc::Rc};
use actix_service::Service;
use actix_web::{

View file

@ -325,7 +325,7 @@ where
}
}
const H2_UNREACHABLE_WRITE: &'static str = "H2Connection can not impl AsyncWrite trait";
const H2_UNREACHABLE_WRITE: &str = "H2Connection can not impl AsyncWrite trait";
impl<A, B> AsyncWrite for Connection<A, B>
where

View file

@ -126,9 +126,7 @@ impl ServiceConfig {
pub fn client_timer(&self) -> Option<Sleep> {
let delay_time = self.0.client_timeout;
if delay_time != 0 {
Some(sleep_until(
self.0.date_service.now() + Duration::from_millis(delay_time),
))
Some(sleep_until(self.now() + Duration::from_millis(delay_time)))
} else {
None
}
@ -138,7 +136,7 @@ impl ServiceConfig {
pub fn client_timer_expire(&self) -> Option<Instant> {
let delay = self.0.client_timeout;
if delay != 0 {
Some(self.0.date_service.now() + Duration::from_millis(delay))
Some(self.now() + Duration::from_millis(delay))
} else {
None
}
@ -148,7 +146,7 @@ impl ServiceConfig {
pub fn client_disconnect_timer(&self) -> Option<Instant> {
let delay = self.0.client_disconnect;
if delay != 0 {
Some(self.0.date_service.now() + Duration::from_millis(delay))
Some(self.now() + Duration::from_millis(delay))
} else {
None
}
@ -157,20 +155,12 @@ impl ServiceConfig {
#[inline]
/// Return keep-alive timer delay is configured.
pub fn keep_alive_timer(&self) -> Option<Sleep> {
if let Some(ka) = self.0.keep_alive {
Some(sleep_until(self.0.date_service.now() + ka))
} else {
None
}
self.keep_alive().map(|ka| sleep_until(self.now() + ka))
}
/// Keep-alive expire time
pub fn keep_alive_expire(&self) -> Option<Instant> {
if let Some(ka) = self.0.keep_alive {
Some(self.0.date_service.now() + ka)
} else {
None
}
self.keep_alive().map(|ka| self.now() + ka)
}
#[inline]

View file

@ -127,9 +127,8 @@ impl Display for EntityTag {
impl FromStr for EntityTag {
type Err = crate::error::ParseError;
fn from_str(s: &str) -> Result<EntityTag, crate::error::ParseError> {
let length: usize = s.len();
let slice = &s[..];
fn from_str(slice: &str) -> Result<EntityTag, crate::error::ParseError> {
let length = slice.len();
// Early exits if it doesn't terminate in a DQUOTE.
if !slice.ends_with('"') || slice.len() < 2 {
return Err(crate::error::ParseError::Header);

View file

@ -88,9 +88,9 @@ pub fn parse_extended_value(
};
Ok(ExtendedValue {
value,
charset,
language_tag,
value,
})
}

View file

@ -113,7 +113,7 @@ pub struct AppConfig {
impl AppConfig {
pub(crate) fn new(secure: bool, addr: SocketAddr, host: String) -> Self {
AppConfig { secure, addr, host }
AppConfig { secure, host, addr }
}
/// Server host name.

View file

@ -173,11 +173,7 @@ pub mod dev {
impl BodyEncoding for ResponseBuilder {
fn get_encoding(&self) -> Option<ContentEncoding> {
if let Some(ref enc) = self.extensions().get::<Enc>() {
Some(enc.0)
} else {
None
}
self.extensions().get::<Enc>().map(|enc| enc.0)
}
fn encoding(&mut self, encoding: ContentEncoding) -> &mut Self {
@ -188,11 +184,7 @@ pub mod dev {
impl<B> BodyEncoding for Response<B> {
fn get_encoding(&self) -> Option<ContentEncoding> {
if let Some(ref enc) = self.extensions().get::<Enc>() {
Some(enc.0)
} else {
None
}
self.extensions().get::<Enc>().map(|enc| enc.0)
}
fn encoding(&mut self, encoding: ContentEncoding) -> &mut Self {

View file

@ -197,22 +197,23 @@ impl AcceptEncoding {
/// Parse a raw Accept-Encoding header value into an ordered list.
pub fn parse(raw: &str, encoding: ContentEncoding) -> ContentEncoding {
let mut encodings: Vec<_> = raw
let mut encodings = raw
.replace(' ', "")
.split(',')
.map(|l| AcceptEncoding::new(l))
.collect();
.flatten()
.collect::<Vec<_>>();
encodings.sort();
for enc in encodings {
if let Some(enc) = enc {
if encoding == ContentEncoding::Auto {
return enc.encoding;
} else if encoding == enc.encoding {
return encoding;
}
if encoding == ContentEncoding::Auto {
return enc.encoding;
} else if encoding == enc.encoding {
return encoding;
}
}
ContentEncoding::Identity
}
}

View file

@ -449,9 +449,9 @@ impl ServiceFactory<ServiceRequest> for ResourceFactory {
.collect::<Result<Vec<_>, _>>()?;
Ok(ResourceService {
routes,
app_data,
default,
routes,
})
})
}

View file

@ -774,10 +774,10 @@ where
};
TestServer {
ssl,
addr,
client,
system,
ssl,
server,
}
}

View file

@ -1,15 +1,11 @@
use std::sync::mpsc;
use std::{thread, time::Duration};
#[cfg(feature = "openssl")]
extern crate tls_openssl as openssl;
#[cfg(feature = "rustls")]
extern crate tls_rustls as rustls;
#[cfg(feature = "openssl")]
use openssl::ssl::SslAcceptorBuilder;
use actix_web::{test, web, App, HttpResponse, HttpServer};
#[cfg(any(unix, feature = "openssl"))]
use {
actix_web::{test, web, App, HttpResponse, HttpServer},
std::{sync::mpsc, thread, time::Duration},
};
#[cfg(unix)]
#[actix_rt::test]
@ -72,7 +68,7 @@ async fn test_start() {
}
#[cfg(feature = "openssl")]
fn ssl_acceptor() -> SslAcceptorBuilder {
fn ssl_acceptor() -> openssl::ssl::SslAcceptorBuilder {
use openssl::{
pkey::PKey,
ssl::{SslAcceptor, SslMethod},