diff --git a/src/data.rs b/src/data.rs index bd166b79c..3461d24f3 100644 --- a/src/data.rs +++ b/src/data.rs @@ -118,7 +118,7 @@ impl FromRequest for Data { impl DataFactory for Data { fn create(&self, extensions: &mut Extensions) -> bool { if !extensions.contains::>() { - let _ = extensions.insert(Data(self.0.clone())); + extensions.insert(Data(self.0.clone())); true } else { false diff --git a/src/handler.rs b/src/handler.rs index bd0b35517..078abbf1d 100644 --- a/src/handler.rs +++ b/src/handler.rs @@ -250,7 +250,7 @@ where Ok(Async::Ready(res)) => { self.fut2 = Some(res.respond_to(self.req.as_ref().unwrap()).into_future()); - return self.poll(); + self.poll() } Ok(Async::NotReady) => Ok(Async::NotReady), Err(e) => { diff --git a/src/info.rs b/src/info.rs index e9b375875..a6a7d7282 100644 --- a/src/info.rs +++ b/src/info.rs @@ -25,7 +25,7 @@ impl ConnectionInfo { Ref::map(req.extensions(), |e| e.get().unwrap()) } - #[allow(clippy::cyclomatic_complexity)] + #[allow(clippy::cyclomatic_complexity, clippy::cognitive_complexity, clippy::borrow_interior_mutable_const)] fn new(req: &RequestHead, cfg: &AppConfig) -> ConnectionInfo { let mut host = None; let mut scheme = None; diff --git a/src/lib.rs b/src/lib.rs index fffbc2f5e..345987ffa 100644 --- a/src/lib.rs +++ b/src/lib.rs @@ -134,6 +134,8 @@ pub mod dev { //! ``` pub use crate::config::{AppConfig, AppService}; + #[doc(hidden)] + pub use crate::handler::{AsyncFactory, Factory}; pub use crate::info::ConnectionInfo; pub use crate::rmap::ResourceMap; pub use crate::service::{ diff --git a/src/middleware/compress.rs b/src/middleware/compress.rs index 86665d824..c9d2107f4 100644 --- a/src/middleware/compress.rs +++ b/src/middleware/compress.rs @@ -107,6 +107,7 @@ where self.service.poll_ready() } + #[allow(clippy::borrow_interior_mutable_const)] fn call(&mut self, req: ServiceRequest) -> Self::Future { // negotiate content-encoding let encoding = if let Some(val) = req.headers().get(&ACCEPT_ENCODING) { diff --git a/src/middleware/defaultheaders.rs b/src/middleware/defaultheaders.rs index ab2d36c2c..a353f5fc5 100644 --- a/src/middleware/defaultheaders.rs +++ b/src/middleware/defaultheaders.rs @@ -125,6 +125,7 @@ where self.service.poll_ready() } + #[allow(clippy::borrow_interior_mutable_const)] fn call(&mut self, req: ServiceRequest) -> Self::Future { let inner = self.inner.clone(); diff --git a/src/middleware/logger.rs b/src/middleware/logger.rs index d47e45023..24aabb95d 100644 --- a/src/middleware/logger.rs +++ b/src/middleware/logger.rs @@ -415,9 +415,9 @@ impl FormatText { )) }; } - FormatText::UrlPath => *self = FormatText::Str(format!("{}", req.path())), + FormatText::UrlPath => *self = FormatText::Str(req.path().to_string()), FormatText::RequestTime => { - *self = FormatText::Str(format!("{}", now.rfc3339())) + *self = FormatText::Str(now.rfc3339().to_string()) } FormatText::RequestHeader(ref name) => { let s = if let Some(val) = req.headers().get(name) { diff --git a/src/resource.rs b/src/resource.rs index d09beb27b..0d66aa843 100644 --- a/src/resource.rs +++ b/src/resource.rs @@ -426,7 +426,7 @@ where fn into_new_service(self) -> T { *self.factory_ref.borrow_mut() = Some(ResourceFactory { routes: self.routes, - data: self.data.map(|data| Rc::new(data)), + data: self.data.map(Rc::new), default: self.default, }); diff --git a/src/rmap.rs b/src/rmap.rs index cad62dca0..42ddb1349 100644 --- a/src/rmap.rs +++ b/src/rmap.rs @@ -123,7 +123,7 @@ impl ResourceMap { I: AsRef, { if let Some(pattern) = self.named.get(name) { - if pattern.pattern().starts_with("/") { + if pattern.pattern().starts_with('/') { self.fill_root(path, elements)?; } if pattern.resource_path(path, elements) { diff --git a/src/scope.rs b/src/scope.rs index 99afd7d16..714f0354a 100644 --- a/src/scope.rs +++ b/src/scope.rs @@ -195,7 +195,7 @@ where self.external.extend(cfg.external); if !cfg.data.is_empty() { - let mut data = self.data.unwrap_or_else(|| Extensions::new()); + let mut data = self.data.unwrap_or_else(Extensions::new); for value in cfg.data.iter() { value.create(&mut data); @@ -425,7 +425,7 @@ where // complete scope pipeline creation *self.factory_ref.borrow_mut() = Some(ScopeFactory { - data: self.data.take().map(|data| Rc::new(data)), + data: self.data.take().map(Rc::new), default: self.default.clone(), services: Rc::new( cfg.into_services() diff --git a/src/types/form.rs b/src/types/form.rs index e61145b0d..ac202b17d 100644 --- a/src/types/form.rs +++ b/src/types/form.rs @@ -192,6 +192,7 @@ pub struct UrlEncoded { impl UrlEncoded { /// Create a new future to URL encode a request + #[allow(clippy::borrow_interior_mutable_const)] pub fn new(req: &HttpRequest, payload: &mut Payload) -> UrlEncoded { // check content type if req.content_type().to_lowercase() != "application/x-www-form-urlencoded" { diff --git a/src/types/json.rs b/src/types/json.rs index f309a3c5a..70feef8d3 100644 --- a/src/types/json.rs +++ b/src/types/json.rs @@ -298,6 +298,7 @@ where U: DeserializeOwned + 'static, { /// Create `JsonBody` for request. + #[allow(clippy::borrow_interior_mutable_const)] pub fn new( req: &HttpRequest, payload: &mut Payload, diff --git a/src/types/payload.rs b/src/types/payload.rs index 8a634b4c9..34c3e2984 100644 --- a/src/types/payload.rs +++ b/src/types/payload.rs @@ -298,6 +298,7 @@ pub struct HttpMessageBody { impl HttpMessageBody { /// Create `MessageBody` for request. + #[allow(clippy::borrow_interior_mutable_const)] pub fn new(req: &HttpRequest, payload: &mut dev::Payload) -> HttpMessageBody { let mut len = None; if let Some(l) = req.headers().get(&header::CONTENT_LENGTH) {