diff --git a/actix-cors/src/inner.rs b/actix-cors/src/inner.rs index dc3d5934c..523c1d8cc 100644 --- a/actix-cors/src/inner.rs +++ b/actix-cors/src/inner.rs @@ -1,4 +1,9 @@ -use std::{collections::HashSet, convert::TryFrom, convert::TryInto, fmt, rc::Rc}; +use std::{ + collections::HashSet, + convert::{TryFrom, TryInto}, + fmt, + rc::Rc, +}; use actix_web::{ dev::RequestHead, diff --git a/actix-cors/tests/tests.rs b/actix-cors/tests/tests.rs index b0ff02b91..1f4f94a84 100644 --- a/actix-cors/tests/tests.rs +++ b/actix-cors/tests/tests.rs @@ -1,8 +1,7 @@ use actix_cors::Cors; use actix_utils::future::ok; -use actix_web::dev::fn_service; use actix_web::{ - dev::{ServiceRequest, Transform}, + dev::{fn_service, ServiceRequest, Transform}, http::{ header::{self, HeaderValue}, Method, StatusCode, diff --git a/actix-identity/src/lib.rs b/actix-identity/src/lib.rs index 9ef232a52..d2fbfff9a 100644 --- a/actix-identity/src/lib.rs +++ b/actix-identity/src/lib.rs @@ -95,6 +95,4 @@ mod identity; mod identity_ext; mod middleware; -pub use self::identity::Identity; -pub use self::identity_ext::IdentityExt; -pub use self::middleware::IdentityMiddleware; +pub use self::{identity::Identity, identity_ext::IdentityExt, middleware::IdentityMiddleware}; diff --git a/actix-limitation/src/lib.rs b/actix-limitation/src/lib.rs index 6d2ab63db..384f51dad 100644 --- a/actix-limitation/src/lib.rs +++ b/actix-limitation/src/lib.rs @@ -60,10 +60,7 @@ mod errors; mod middleware; mod status; -pub use self::builder::Builder; -pub use self::errors::Error; -pub use self::middleware::RateLimiter; -pub use self::status::Status; +pub use self::{builder::Builder, errors::Error, middleware::RateLimiter, status::Status}; /// Default request limit. pub const DEFAULT_REQUEST_LIMIT: usize = 5000; diff --git a/actix-protobuf/src/lib.rs b/actix-protobuf/src/lib.rs index f7a8bedcb..743a51d56 100644 --- a/actix-protobuf/src/lib.rs +++ b/actix-protobuf/src/lib.rs @@ -266,14 +266,14 @@ impl ProtoBufResponseBuilder for HttpResponseBuilder { value .encode(&mut body) .map_err(ProtoBufPayloadError::Serialize)?; + Ok(self.body(body)) } } #[cfg(test)] mod tests { - use actix_web::http::header; - use actix_web::test::TestRequest; + use actix_web::{http::header, test::TestRequest}; use super::*; diff --git a/actix-session/src/lib.rs b/actix-session/src/lib.rs index e115a4ebf..f48c9ac40 100644 --- a/actix-session/src/lib.rs +++ b/actix-session/src/lib.rs @@ -146,9 +146,11 @@ mod session; mod session_ext; pub mod storage; -pub use self::middleware::SessionMiddleware; -pub use self::session::{Session, SessionGetError, SessionInsertError, SessionStatus}; -pub use self::session_ext::SessionExt; +pub use self::{ + middleware::SessionMiddleware, + session::{Session, SessionGetError, SessionInsertError, SessionStatus}, + session_ext::SessionExt, +}; #[cfg(test)] pub mod test_helpers { @@ -207,9 +209,11 @@ pub mod test_helpers { use serde::{Deserialize, Serialize}; use serde_json::json; - use crate::config::{CookieContentSecurity, PersistentSession, TtlExtensionPolicy}; use crate::{ - storage::SessionStore, test_helpers::key, Session, SessionExt, SessionMiddleware, + config::{CookieContentSecurity, PersistentSession, TtlExtensionPolicy}, + storage::SessionStore, + test_helpers::key, + Session, SessionExt, SessionMiddleware, }; pub(super) async fn basic_workflow( diff --git a/actix-session/src/storage/mod.rs b/actix-session/src/storage/mod.rs index 1a74a8c6f..17508850f 100644 --- a/actix-session/src/storage/mod.rs +++ b/actix-session/src/storage/mod.rs @@ -3,8 +3,10 @@ mod interface; mod session_key; -pub use self::interface::{LoadError, SaveError, SessionStore, UpdateError}; -pub use self::session_key::SessionKey; +pub use self::{ + interface::{LoadError, SaveError, SessionStore, UpdateError}, + session_key::SessionKey, +}; #[cfg(feature = "cookie-session")] mod cookie; diff --git a/actix-session/tests/opaque_errors.rs b/actix-session/tests/opaque_errors.rs index 378a34752..d0af675c5 100644 --- a/actix-session/tests/opaque_errors.rs +++ b/actix-session/tests/opaque_errors.rs @@ -1,13 +1,14 @@ -use std::collections::HashMap; -use std::convert::TryInto; +use std::{collections::HashMap, convert::TryInto}; -use actix_session::storage::{LoadError, SaveError, SessionKey, SessionStore, UpdateError}; -use actix_session::{Session, SessionMiddleware}; -use actix_web::body::MessageBody; -use actix_web::http::StatusCode; +use actix_session::{ + storage::{LoadError, SaveError, SessionKey, SessionStore, UpdateError}, + Session, SessionMiddleware, +}; use actix_web::{ + body::MessageBody, cookie::{time::Duration, Key}, dev::Service, + http::StatusCode, test, web, App, Responder, }; use anyhow::Error; diff --git a/actix-settings/src/lib.rs b/actix-settings/src/lib.rs index ed8b4bc84..8383dc015 100644 --- a/actix-settings/src/lib.rs +++ b/actix-settings/src/lib.rs @@ -89,11 +89,13 @@ mod error; mod parse; mod settings; -pub use self::error::Error; -pub use self::parse::Parse; -pub use self::settings::{ - ActixSettings, Address, Backlog, KeepAlive, MaxConnectionRate, MaxConnections, Mode, - NumWorkers, Timeout, Tls, +pub use self::{ + error::Error, + parse::Parse, + settings::{ + ActixSettings, Address, Backlog, KeepAlive, MaxConnectionRate, MaxConnections, Mode, + NumWorkers, Timeout, Tls, + }, }; /// Convenience type alias for `Result`. diff --git a/actix-settings/src/settings/mod.rs b/actix-settings/src/settings/mod.rs index e3ff645ea..839649e14 100644 --- a/actix-settings/src/settings/mod.rs +++ b/actix-settings/src/settings/mod.rs @@ -10,15 +10,11 @@ mod num_workers; mod timeout; mod tls; -pub use self::address::Address; -pub use self::backlog::Backlog; -pub use self::keep_alive::KeepAlive; -pub use self::max_connection_rate::MaxConnectionRate; -pub use self::max_connections::MaxConnections; -pub use self::mode::Mode; -pub use self::num_workers::NumWorkers; -pub use self::timeout::Timeout; -pub use self::tls::Tls; +pub use self::{ + address::Address, backlog::Backlog, keep_alive::KeepAlive, + max_connection_rate::MaxConnectionRate, max_connections::MaxConnections, mode::Mode, + num_workers::NumWorkers, timeout::Timeout, tls::Tls, +}; /// Settings types for Actix Web. #[derive(Debug, Clone, PartialEq, Eq, Hash, Deserialize)] diff --git a/actix-web-httpauth/examples/middleware.rs b/actix-web-httpauth/examples/middleware.rs index 487f96346..d3671c1a7 100644 --- a/actix-web-httpauth/examples/middleware.rs +++ b/actix-web-httpauth/examples/middleware.rs @@ -1,7 +1,5 @@ -use actix_web::dev::ServiceRequest; -use actix_web::{middleware, web, App, Error, HttpServer}; -use actix_web_httpauth::extractors::basic::BasicAuth; -use actix_web_httpauth::middleware::HttpAuthentication; +use actix_web::{dev::ServiceRequest, middleware, web, App, Error, HttpServer}; +use actix_web_httpauth::{extractors::basic::BasicAuth, middleware::HttpAuthentication}; async fn validator( req: ServiceRequest, diff --git a/actix-web-httpauth/src/extractors/mod.rs b/actix-web-httpauth/src/extractors/mod.rs index d2098a940..bd652b1f7 100644 --- a/actix-web-httpauth/src/extractors/mod.rs +++ b/actix-web-httpauth/src/extractors/mod.rs @@ -5,5 +5,4 @@ pub mod bearer; mod config; mod errors; -pub use self::config::AuthExtractorConfig; -pub use self::errors::AuthenticationError; +pub use self::{config::AuthExtractorConfig, errors::AuthenticationError}; diff --git a/actix-web-httpauth/src/headers/authorization/mod.rs b/actix-web-httpauth/src/headers/authorization/mod.rs index cd9cb01c8..f5a9ab4be 100644 --- a/actix-web-httpauth/src/headers/authorization/mod.rs +++ b/actix-web-httpauth/src/headers/authorization/mod.rs @@ -4,6 +4,8 @@ mod errors; mod header; mod scheme; -pub use self::errors::ParseError; -pub use self::header::Authorization; -pub use self::scheme::{basic::Basic, bearer::Bearer, Scheme}; +pub use self::{ + errors::ParseError, + header::Authorization, + scheme::{basic::Basic, bearer::Bearer, Scheme}, +}; diff --git a/actix-web-httpauth/src/headers/www_authenticate/challenge/bearer/challenge.rs b/actix-web-httpauth/src/headers/www_authenticate/challenge/bearer/challenge.rs index 3c420cee5..494f7de31 100644 --- a/actix-web-httpauth/src/headers/www_authenticate/challenge/bearer/challenge.rs +++ b/actix-web-httpauth/src/headers/www_authenticate/challenge/bearer/challenge.rs @@ -5,8 +5,7 @@ use actix_web::{ web::{BufMut, Bytes, BytesMut}, }; -use super::super::Challenge; -use super::{BearerBuilder, Error}; +use super::{super::Challenge, BearerBuilder, Error}; use crate::utils; /// Challenge for [`WWW-Authenticate`] header with HTTP Bearer auth scheme, described in [RFC 6750]. diff --git a/actix-web-httpauth/src/headers/www_authenticate/challenge/bearer/mod.rs b/actix-web-httpauth/src/headers/www_authenticate/challenge/bearer/mod.rs index effb1db3b..f957dedc4 100644 --- a/actix-web-httpauth/src/headers/www_authenticate/challenge/bearer/mod.rs +++ b/actix-web-httpauth/src/headers/www_authenticate/challenge/bearer/mod.rs @@ -4,9 +4,7 @@ mod builder; mod challenge; mod errors; -pub use self::builder::BearerBuilder; -pub use self::challenge::Bearer; -pub use self::errors::Error; +pub use self::{builder::BearerBuilder, challenge::Bearer, errors::Error}; #[cfg(test)] mod tests { diff --git a/actix-web-httpauth/src/headers/www_authenticate/mod.rs b/actix-web-httpauth/src/headers/www_authenticate/mod.rs index f7ed690cc..487883bf4 100644 --- a/actix-web-httpauth/src/headers/www_authenticate/mod.rs +++ b/actix-web-httpauth/src/headers/www_authenticate/mod.rs @@ -3,5 +3,7 @@ mod challenge; mod header; -pub use self::challenge::{basic, bearer, Challenge}; -pub use self::header::WwwAuthenticate; +pub use self::{ + challenge::{basic, bearer, Challenge}, + header::WwwAuthenticate, +}; diff --git a/rustfmt.toml b/rustfmt.toml index 38b9e24df..71b9be3ae 100644 --- a/rustfmt.toml +++ b/rustfmt.toml @@ -1,2 +1,3 @@ -reorder_imports = true group_imports = "StdExternalCrate" +imports_granularity = "Crate" +use_field_init_shorthand = true