diff --git a/actix-codec/src/lib.rs b/actix-codec/src/lib.rs
index 6914b306..db1f90de 100644
--- a/actix-codec/src/lib.rs
+++ b/actix-codec/src/lib.rs
@@ -16,10 +16,10 @@ mod bcodec;
mod framed;
mod lines;
-pub use self::bcodec::BytesCodec;
-pub use self::framed::{Framed, FramedParts};
-pub use self::lines::LinesCodec;
-
pub use tokio::io::{AsyncRead, AsyncWrite, ReadBuf};
pub use tokio_util::codec::{Decoder, Encoder};
pub use tokio_util::io::poll_read_buf;
+
+pub use self::bcodec::BytesCodec;
+pub use self::framed::{Framed, FramedParts};
+pub use self::lines::LinesCodec;
diff --git a/actix-codec/tests/test_framed_sink.rs b/actix-codec/tests/test_framed_sink.rs
index 15c3c292..390aebf2 100644
--- a/actix-codec/tests/test_framed_sink.rs
+++ b/actix-codec/tests/test_framed_sink.rs
@@ -1,12 +1,16 @@
+use std::{
+ collections::VecDeque,
+ io::{self, Write},
+ pin::Pin,
+ task::{
+ Context,
+ Poll::{self, Pending, Ready},
+ },
+};
+
use actix_codec::*;
-use bytes::Buf;
-use bytes::{BufMut, BytesMut};
+use bytes::{Buf as _, BufMut as _, BytesMut};
use futures_sink::Sink;
-use std::collections::VecDeque;
-use std::io::{self, Write};
-use std::pin::Pin;
-use std::task::Poll::{Pending, Ready};
-use std::task::{Context, Poll};
use tokio_test::{assert_ready, task};
macro_rules! bilateral {
diff --git a/actix-rt/examples/hyper.rs b/actix-rt/examples/hyper.rs
index 3520acd0..45b5e551 100644
--- a/actix-rt/examples/hyper.rs
+++ b/actix-rt/examples/hyper.rs
@@ -1,7 +1,9 @@
-use hyper::service::{make_service_fn, service_fn};
-use hyper::{Body, Request, Response, Server};
-use std::convert::Infallible;
-use std::net::SocketAddr;
+use std::{convert::Infallible, net::SocketAddr};
+
+use hyper::{
+ service::{make_service_fn, service_fn},
+ Body, Request, Response, Server,
+};
async fn handle(_req: Request
) -> Result, Infallible> {
Ok(Response::new(Body::from("Hello World")))
diff --git a/actix-rt/src/lib.rs b/actix-rt/src/lib.rs
index 7fb2b632..b2d5f893 100644
--- a/actix-rt/src/lib.rs
+++ b/actix-rt/src/lib.rs
@@ -51,13 +51,10 @@ compile_error!("io_uring is a linux only feature.");
use std::future::Future;
-use tokio::task::JoinHandle;
-
// Cannot define a main macro when compiled into test harness.
// Workaround for https://github.com/rust-lang/rust/issues/62127.
#[cfg(all(feature = "macros", not(test)))]
pub use actix_macros::main;
-
#[cfg(feature = "macros")]
pub use actix_macros::test;
@@ -65,12 +62,13 @@ mod arbiter;
mod runtime;
mod system;
+pub use tokio::pin;
+use tokio::task::JoinHandle;
+
pub use self::arbiter::{Arbiter, ArbiterHandle};
pub use self::runtime::Runtime;
pub use self::system::{System, SystemRunner};
-pub use tokio::pin;
-
pub mod signal {
//! Asynchronous signal handling (Tokio re-exports).
@@ -95,7 +93,6 @@ pub mod net {
use tokio::io::{AsyncRead, AsyncWrite, Interest};
pub use tokio::net::UdpSocket;
pub use tokio::net::{TcpListener, TcpSocket, TcpStream};
-
#[cfg(unix)]
pub use tokio::net::{UnixDatagram, UnixListener, UnixStream};
diff --git a/actix-rt/tests/tests.rs b/actix-rt/tests/tests.rs
index 551a395d..be7c3248 100644
--- a/actix-rt/tests/tests.rs
+++ b/actix-rt/tests/tests.rs
@@ -4,7 +4,6 @@ use std::{
};
use actix_rt::{task::JoinError, Arbiter, System};
-
#[cfg(not(feature = "io-uring"))]
use {
std::{sync::mpsc::channel, thread},
diff --git a/actix-server/src/join_all.rs b/actix-server/src/join_all.rs
index bdef62ef..e9bd8949 100644
--- a/actix-server/src/join_all.rs
+++ b/actix-server/src/join_all.rs
@@ -63,10 +63,10 @@ impl Future for JoinAll {
#[cfg(test)]
mod test {
- use super::*;
-
use actix_utils::future::ready;
+ use super::*;
+
#[actix_rt::test]
async fn test_join_all() {
let futs = vec![ready(Ok(1)), ready(Err(3)), ready(Ok(9))];
diff --git a/actix-server/src/lib.rs b/actix-server/src/lib.rs
index 9bbb33a0..532313b6 100644
--- a/actix-server/src/lib.rs
+++ b/actix-server/src/lib.rs
@@ -22,10 +22,9 @@ pub use self::builder::ServerBuilder;
pub use self::handle::ServerHandle;
pub use self::server::Server;
pub use self::service::ServerServiceFactory;
-pub use self::test_server::TestServer;
-
#[doc(hidden)]
pub use self::socket::FromStream;
+pub use self::test_server::TestServer;
/// Start server building process
#[doc(hidden)]
diff --git a/actix-server/src/socket.rs b/actix-server/src/socket.rs
index 25291fd2..8d2ffe8f 100644
--- a/actix-server/src/socket.rs
+++ b/actix-server/src/socket.rs
@@ -6,7 +6,6 @@ use std::{fmt, io};
use actix_rt::net::TcpStream;
pub(crate) use mio::net::TcpListener as MioTcpListener;
use mio::{event::Source, Interest, Registry, Token};
-
#[cfg(unix)]
pub(crate) use {
mio::net::UnixListener as MioUnixListener,
diff --git a/actix-service/src/fn_service.rs b/actix-service/src/fn_service.rs
index ae22e39b..a2379270 100644
--- a/actix-service/src/fn_service.rs
+++ b/actix-service/src/fn_service.rs
@@ -394,9 +394,10 @@ mod tests {
#[actix_rt::test]
async fn test_auto_impl_send() {
- use crate::{map_config, ServiceExt, ServiceFactoryExt};
use alloc::rc::Rc;
+ use crate::{map_config, ServiceExt, ServiceFactoryExt};
+
let srv_1 = fn_service(|_: Rc| ok::<_, Rc>(Rc::new(0u8)));
let fac_1 = fn_factory_with_config(|_: Rc| {
diff --git a/actix-service/src/lib.rs b/actix-service/src/lib.rs
index 96a6b164..091a7fd7 100644
--- a/actix-service/src/lib.rs
+++ b/actix-service/src/lib.rs
@@ -38,10 +38,9 @@ pub use self::apply_cfg::{apply_cfg, apply_cfg_factory};
pub use self::ext::{ServiceExt, ServiceFactoryExt, TransformExt};
pub use self::fn_service::{fn_factory, fn_factory_with_config, fn_service};
pub use self::map_config::{map_config, unit_config};
-pub use self::transform::{apply, ApplyTransform, Transform};
-
#[allow(unused_imports)]
use self::ready::{err, ok, ready, Ready};
+pub use self::transform::{apply, ApplyTransform, Transform};
/// An asynchronous operation from `Request` to a `Response`.
///
diff --git a/actix-tls/examples/accept-rustls.rs b/actix-tls/examples/accept-rustls.rs
index 0ea1e7e1..6a90616d 100644
--- a/actix-tls/examples/accept-rustls.rs
+++ b/actix-tls/examples/accept-rustls.rs
@@ -15,8 +15,9 @@
//! http --verify=false https://127.0.0.1:8443
//! ```
-// this use only exists because of how we have organised the crate
-// it is not necessary for your actual code
+#[rustfmt::skip]
+// this `use` is only exists because of how we have organised the crate
+// it is not necessary for your actual code; you should import from `rustls` directly
use tokio_rustls::rustls;
use std::{
diff --git a/actix-tls/src/connect/native_tls.rs b/actix-tls/src/connect/native_tls.rs
index 74a24c22..ecd9462e 100644
--- a/actix-tls/src/connect/native_tls.rs
+++ b/actix-tls/src/connect/native_tls.rs
@@ -20,7 +20,6 @@ pub mod reexports {
//! Re-exports from `native-tls` and `tokio-native-tls` that are useful for connectors.
pub use tokio_native_tls::native_tls::TlsConnector;
-
pub use tokio_native_tls::TlsStream as AsyncTlsStream;
}
diff --git a/actix-tls/src/connect/openssl.rs b/actix-tls/src/connect/openssl.rs
index 5558baed..2fc534fd 100644
--- a/actix-tls/src/connect/openssl.rs
+++ b/actix-tls/src/connect/openssl.rs
@@ -25,7 +25,6 @@ pub mod reexports {
pub use openssl::ssl::{
Error, HandshakeError, SslConnector, SslConnectorBuilder, SslMethod,
};
-
pub use tokio_openssl::SslStream as AsyncSslStream;
}
diff --git a/actix-tls/src/connect/rustls.rs b/actix-tls/src/connect/rustls.rs
index 8d74fd8a..d3b27c93 100644
--- a/actix-tls/src/connect/rustls.rs
+++ b/actix-tls/src/connect/rustls.rs
@@ -26,10 +26,8 @@ use crate::connect::{Connection, Host};
pub mod reexports {
//! Re-exports from `rustls` and `webpki_roots` that are useful for connectors.
- pub use tokio_rustls::rustls::ClientConfig;
-
pub use tokio_rustls::client::TlsStream as AsyncTlsStream;
-
+ pub use tokio_rustls::rustls::ClientConfig;
pub use webpki_roots::TLS_SERVER_ROOTS;
}
diff --git a/actix-tls/tests/accept-openssl.rs b/actix-tls/tests/accept-openssl.rs
index 4b6fadf0..a4180f4d 100644
--- a/actix-tls/tests/accept-openssl.rs
+++ b/actix-tls/tests/accept-openssl.rs
@@ -51,13 +51,13 @@ fn openssl_acceptor(cert: String, key: String) -> tls_openssl::ssl::SslAcceptor
mod danger {
use std::time::SystemTime;
- use super::*;
-
use tokio_rustls::rustls::{
self,
client::{ServerCertVerified, ServerCertVerifier},
};
+ use super::*;
+
pub struct NoCertificateVerification;
impl ServerCertVerifier for NoCertificateVerification {
diff --git a/actix-tls/tests/test_connect.rs b/actix-tls/tests/test_connect.rs
index bdd6b49c..7f8212b0 100644
--- a/actix-tls/tests/test_connect.rs
+++ b/actix-tls/tests/test_connect.rs
@@ -9,11 +9,10 @@ use actix_codec::{BytesCodec, Framed};
use actix_rt::net::TcpStream;
use actix_server::TestServer;
use actix_service::{fn_service, Service, ServiceFactory};
+use actix_tls::connect::{ConnectError, ConnectInfo, Connection, Connector, Host};
use bytes::Bytes;
use futures_util::sink::SinkExt;
-use actix_tls::connect::{ConnectError, ConnectInfo, Connection, Connector, Host};
-
#[cfg(feature = "openssl")]
#[actix_rt::test]
async fn test_string() {
diff --git a/actix-tls/tests/test_resolvers.rs b/actix-tls/tests/test_resolvers.rs
index 81bbec54..f0674383 100644
--- a/actix-tls/tests/test_resolvers.rs
+++ b/actix-tls/tests/test_resolvers.rs
@@ -8,11 +8,10 @@ use std::{
use actix_rt::net::TcpStream;
use actix_server::TestServer;
use actix_service::{fn_service, Service, ServiceFactory};
-use futures_core::future::LocalBoxFuture;
-
use actix_tls::connect::{
ConnectError, ConnectInfo, Connection, Connector, Host, Resolve, Resolver,
};
+use futures_core::future::LocalBoxFuture;
#[actix_rt::test]
async fn custom_resolver() {
diff --git a/actix-tracing/src/lib.rs b/actix-tracing/src/lib.rs
index a12f6d05..f5b08927 100644
--- a/actix-tracing/src/lib.rs
+++ b/actix-tracing/src/lib.rs
@@ -118,8 +118,6 @@ where
#[cfg(test)]
mod test {
- use super::*;
-
use std::cell::RefCell;
use std::collections::{BTreeMap, BTreeSet};
use std::sync::{Arc, RwLock};
@@ -128,6 +126,8 @@ mod test {
use slab::Slab;
use tracing::{span, Event, Level, Metadata, Subscriber};
+ use super::*;
+
thread_local! {
static SPAN: RefCell> = RefCell::new(Vec::new());
}
diff --git a/bytestring/src/lib.rs b/bytestring/src/lib.rs
index 7ab5a291..95a21870 100644
--- a/bytestring/src/lib.rs
+++ b/bytestring/src/lib.rs
@@ -219,11 +219,11 @@ mod serde {
#[cfg(test)]
mod serde_impl_tests {
- use super::*;
-
use serde::de::DeserializeOwned;
use static_assertions::assert_impl_all;
+ use super::*;
+
assert_impl_all!(ByteString: Serialize, DeserializeOwned);
}
}
diff --git a/rustfmt.toml b/rustfmt.toml
index 973e002c..a8758a07 100644
--- a/rustfmt.toml
+++ b/rustfmt.toml
@@ -1,2 +1,2 @@
max_width = 96
-reorder_imports = true
+group_imports = "StdExternalCrate"