diff --git a/.github/workflows/ci.yml b/.github/workflows/ci.yml index f59d79e9..cd9c5848 100644 --- a/.github/workflows/ci.yml +++ b/.github/workflows/ci.yml @@ -23,7 +23,7 @@ jobs: - { name: Windows (MinGW), os: windows-latest, triple: x86_64-pc-windows-gnu } - { name: Windows (32-bit), os: windows-latest, triple: i686-pc-windows-msvc } version: - - 1.60.0 + - 1.65.0 # MSRV - stable name: ${{ matrix.target.name }} / ${{ matrix.version }} diff --git a/.rustfmt.toml b/.rustfmt.toml new file mode 100644 index 00000000..71b9be3a --- /dev/null +++ b/.rustfmt.toml @@ -0,0 +1,3 @@ +group_imports = "StdExternalCrate" +imports_granularity = "Crate" +use_field_init_shorthand = true diff --git a/Cargo.toml b/Cargo.toml index ccd36595..62897764 100644 --- a/Cargo.toml +++ b/Cargo.toml @@ -14,6 +14,10 @@ members = [ ] resolver = "2" +[workspace.package] +edition = "2021" +rust-version = "1.65" + [patch.crates-io] actix-codec = { path = "actix-codec" } actix-macros = { path = "actix-macros" } diff --git a/README.md b/README.md index fdf829f5..9d99d5ee 100644 --- a/README.md +++ b/README.md @@ -13,7 +13,7 @@ See example folders for [`actix-server`](./actix-server/examples) and [`actix-tl ## MSRV -Crates in this repo currently have a Minimum Supported Rust Version (MSRV) of 1.60. As a policy, we permit MSRV increases in non-breaking releases. +Crates in this repo currently have a Minimum Supported Rust Version (MSRV) of 1.65. As a policy, we permit MSRV increases in non-breaking releases. ## License diff --git a/actix-codec/CHANGES.md b/actix-codec/CHANGES.md index ebb867cf..14dc78c5 100644 --- a/actix-codec/CHANGES.md +++ b/actix-codec/CHANGES.md @@ -2,7 +2,7 @@ ## Unreleased - 2023-xx-xx -- Minimum supported Rust version (MSRV) is now 1.60. +- Minimum supported Rust version (MSRV) is now 1.65. ## 0.5.1 - 2022-03-15 diff --git a/actix-codec/Cargo.toml b/actix-codec/Cargo.toml index 565bc830..d8f072df 100644 --- a/actix-codec/Cargo.toml +++ b/actix-codec/Cargo.toml @@ -10,8 +10,8 @@ keywords = ["network", "framework", "async", "futures"] repository = "https://github.com/actix/actix-net" categories = ["network-programming", "asynchronous"] license = "MIT OR Apache-2.0" -edition = "2021" -rust-version = "1.60" +edition.workspace = true +rust-version.workspace = true [dependencies] bitflags = "2" diff --git a/actix-codec/src/framed.rs b/actix-codec/src/framed.rs index 0d62a61c..6d6e1478 100644 --- a/actix-codec/src/framed.rs +++ b/actix-codec/src/framed.rs @@ -234,10 +234,7 @@ impl Framed { } /// Flush write buffer to underlying I/O stream. - pub fn flush( - mut self: Pin<&mut Self>, - cx: &mut Context<'_>, - ) -> Poll> + pub fn flush(mut self: Pin<&mut Self>, cx: &mut Context<'_>) -> Poll> where T: AsyncWrite, U: Encoder, @@ -270,10 +267,7 @@ impl Framed { } /// Flush write buffer and shutdown underlying I/O stream. - pub fn close( - mut self: Pin<&mut Self>, - cx: &mut Context<'_>, - ) -> Poll> + pub fn close(mut self: Pin<&mut Self>, cx: &mut Context<'_>) -> Poll> where T: AsyncWrite, U: Encoder, diff --git a/actix-codec/src/lib.rs b/actix-codec/src/lib.rs index 020e40e2..7dc28b35 100644 --- a/actix-codec/src/lib.rs +++ b/actix-codec/src/lib.rs @@ -11,14 +11,18 @@ #![doc(html_logo_url = "https://actix.rs/img/logo.png")] #![doc(html_favicon_url = "https://actix.rs/favicon.ico")] +pub use tokio::io::{AsyncRead, AsyncWrite, ReadBuf}; +pub use tokio_util::{ + codec::{Decoder, Encoder}, + io::poll_read_buf, +}; + mod bcodec; mod framed; mod lines; -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; +pub use self::{ + bcodec::BytesCodec, + framed::{Framed, FramedParts}, + lines::LinesCodec, +}; diff --git a/actix-codec/tests/test_framed_sink.rs b/actix-codec/tests/test_framed_sink.rs index 390aebf2..8c98ff18 100644 --- a/actix-codec/tests/test_framed_sink.rs +++ b/actix-codec/tests/test_framed_sink.rs @@ -81,10 +81,7 @@ impl AsyncWrite for Bilateral { other => Ready(other), } } - fn poll_shutdown( - self: Pin<&mut Self>, - _cx: &mut Context<'_>, - ) -> Poll> { + fn poll_shutdown(self: Pin<&mut Self>, _cx: &mut Context<'_>) -> Poll> { unimplemented!() } } diff --git a/actix-macros/CHANGES.md b/actix-macros/CHANGES.md index 1badd6b7..9385808c 100644 --- a/actix-macros/CHANGES.md +++ b/actix-macros/CHANGES.md @@ -3,7 +3,7 @@ ## Unreleased - 2023-xx-xx - Update `syn` dependency to `2`. -- Minimum supported Rust version (MSRV) is now 1.60. +- Minimum supported Rust version (MSRV) is now 1.65. ## 0.2.3 - 2021-10-19 diff --git a/actix-macros/Cargo.toml b/actix-macros/Cargo.toml index 902a6dd1..4aba5e53 100644 --- a/actix-macros/Cargo.toml +++ b/actix-macros/Cargo.toml @@ -10,8 +10,8 @@ description = "Macros for Actix system and runtime" repository = "https://github.com/actix/actix-net.git" categories = ["network-programming", "asynchronous"] license = "MIT OR Apache-2.0" -edition = "2021" -rust-version = "1.60" +edition.workspace = true +rust-version.workspace = true [lib] proc-macro = true diff --git a/actix-macros/tests/trybuild.rs b/actix-macros/tests/trybuild.rs index 7e399d49..b37b84ba 100644 --- a/actix-macros/tests/trybuild.rs +++ b/actix-macros/tests/trybuild.rs @@ -1,4 +1,4 @@ -#[rustversion::stable(1.60)] // MSRV +#[rustversion::stable(1.65)] // MSRV #[test] fn compile_macros() { let t = trybuild::TestCases::new(); diff --git a/actix-macros/tests/trybuild/main-02-only-async.stderr b/actix-macros/tests/trybuild/main-02-only-async.stderr index fc060071..2b15ecaa 100644 --- a/actix-macros/tests/trybuild/main-02-only-async.stderr +++ b/actix-macros/tests/trybuild/main-02-only-async.stderr @@ -1,14 +1,11 @@ error: the async keyword is missing from the function declaration - --> $DIR/main-02-only-async.rs:2:1 + --> tests/trybuild/main-02-only-async.rs:2:1 | 2 | fn main() { | ^^ error[E0601]: `main` function not found in crate `$CRATE` - --> $DIR/main-02-only-async.rs:1:1 + --> tests/trybuild/main-02-only-async.rs:4:2 | -1 | / #[actix_rt::main] -2 | | fn main() { -3 | | futures_util::future::ready(()).await -4 | | } - | |_^ consider adding a `main` function to `$DIR/tests/trybuild/main-02-only-async.rs` +4 | } + | ^ consider adding a `main` function to `$DIR/tests/trybuild/main-02-only-async.rs` diff --git a/actix-rt/CHANGES.md b/actix-rt/CHANGES.md index 547b7524..0cedbaa6 100644 --- a/actix-rt/CHANGES.md +++ b/actix-rt/CHANGES.md @@ -2,7 +2,7 @@ ## Unreleased - 2023-xx-xx -- Minimum supported Rust version (MSRV) is now 1.60. +- Minimum supported Rust version (MSRV) is now 1.65. ## 2.8.0 - 2022-12-21 diff --git a/actix-rt/Cargo.toml b/actix-rt/Cargo.toml index fa5fc204..1256eefd 100644 --- a/actix-rt/Cargo.toml +++ b/actix-rt/Cargo.toml @@ -11,8 +11,8 @@ homepage = "https://actix.rs" repository = "https://github.com/actix/actix-net.git" categories = ["network-programming", "asynchronous"] license = "MIT OR Apache-2.0" -edition = "2021" -rust-version = "1.60" +edition.workspace = true +rust-version.workspace = true [features] default = ["macros"] diff --git a/actix-rt/examples/hyper.rs b/actix-rt/examples/hyper.rs index 45b5e551..41c5a7d8 100644 --- a/actix-rt/examples/hyper.rs +++ b/actix-rt/examples/hyper.rs @@ -20,8 +20,7 @@ fn main() { let make_service = make_service_fn(|_conn| async { Ok::<_, Infallible>(service_fn(handle)) }); - let server = - Server::bind(&SocketAddr::from(([127, 0, 0, 1], 3000))).serve(make_service); + let server = Server::bind(&SocketAddr::from(([127, 0, 0, 1], 3000))).serve(make_service); if let Err(err) = server.await { eprintln!("server error: {}", err); diff --git a/actix-rt/src/arbiter.rs b/actix-rt/src/arbiter.rs index a84e25ea..48cc752f 100644 --- a/actix-rt/src/arbiter.rs +++ b/actix-rt/src/arbiter.rs @@ -99,8 +99,7 @@ impl Arbiter { #[allow(clippy::new_without_default)] pub fn new() -> Arbiter { Self::with_tokio_rt(|| { - crate::runtime::default_tokio_runtime() - .expect("Cannot create new Arbiter's Runtime.") + crate::runtime::default_tokio_runtime().expect("Cannot create new Arbiter's Runtime.") }) } @@ -149,9 +148,7 @@ impl Arbiter { .send(SystemCommand::DeregisterArbiter(arb_id)); } }) - .unwrap_or_else(|err| { - panic!("Cannot spawn Arbiter's thread: {:?}. {:?}", &name, err) - }); + .unwrap_or_else(|err| panic!("Cannot spawn Arbiter's thread: {name:?}: {err:?}")); ready_rx.recv().unwrap(); @@ -201,9 +198,7 @@ impl Arbiter { .send(SystemCommand::DeregisterArbiter(arb_id)); } }) - .unwrap_or_else(|err| { - panic!("Cannot spawn Arbiter's thread: {:?}. {:?}", &name, err) - }); + .unwrap_or_else(|err| panic!("Cannot spawn Arbiter's thread: {name:?}: {err:?}")); ready_rx.recv().unwrap(); diff --git a/actix-rt/src/lib.rs b/actix-rt/src/lib.rs index 23dd01e8..6f8057de 100644 --- a/actix-rt/src/lib.rs +++ b/actix-rt/src/lib.rs @@ -65,9 +65,11 @@ 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 self::{ + arbiter::{Arbiter, ArbiterHandle}, + runtime::Runtime, + system::{System, SystemRunner}, +}; pub mod signal { //! Asynchronous signal handling (Tokio re-exports). @@ -89,12 +91,13 @@ pub mod net { task::{Context, Poll}, }; - pub use tokio::io::Ready; 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}; + pub use tokio::{ + io::Ready, + net::{TcpListener, TcpSocket, TcpStream, UdpSocket}, + }; /// Extension trait over async read+write types that can also signal readiness. #[doc(hidden)] @@ -153,10 +156,9 @@ pub mod net { pub mod time { //! Utilities for tracking time (Tokio re-exports). - pub use tokio::time::Instant; - pub use tokio::time::{interval, interval_at, Interval}; - pub use tokio::time::{sleep, sleep_until, Sleep}; - pub use tokio::time::{timeout, Timeout}; + pub use tokio::time::{ + interval, interval_at, sleep, sleep_until, timeout, Instant, Interval, Sleep, Timeout, + }; } pub mod task { diff --git a/actix-rt/src/system.rs b/actix-rt/src/system.rs index d0494a22..7423a01e 100644 --- a/actix-rt/src/system.rs +++ b/actix-rt/src/system.rs @@ -226,9 +226,7 @@ impl SystemRunner { /// Runs the event loop until [stopped](System::stop_with_code), returning the exit code. pub fn run_with_code(self) -> io::Result { - unimplemented!( - "SystemRunner::run_with_code is not implemented for io-uring feature yet" - ); + unimplemented!("SystemRunner::run_with_code is not implemented for io-uring feature yet"); } /// Runs the provided future, blocking the current thread until the future completes. diff --git a/actix-server/CHANGES.md b/actix-server/CHANGES.md index 1147dcbd..e98f9d2b 100644 --- a/actix-server/CHANGES.md +++ b/actix-server/CHANGES.md @@ -2,7 +2,7 @@ ## Unreleased - 2023-xx-xx -- Minimum supported Rust version (MSRV) is now 1.60. +- Minimum supported Rust version (MSRV) is now 1.65. ## 2.2.0 - 2022-12-21 diff --git a/actix-server/Cargo.toml b/actix-server/Cargo.toml index ade711f4..62f13107 100755 --- a/actix-server/Cargo.toml +++ b/actix-server/Cargo.toml @@ -12,8 +12,8 @@ categories = ["network-programming", "asynchronous"] homepage = "https://actix.rs" repository = "https://github.com/actix/actix-net.git" license = "MIT OR Apache-2.0" -edition = "2021" -rust-version = "1.60" +edition.workspace = true +rust-version.workspace = true [features] default = [] @@ -28,7 +28,7 @@ futures-core = { version = "0.3.17", default-features = false, features = ["allo futures-util = { version = "0.3.17", default-features = false, features = ["alloc"] } mio = { version = "0.8", features = ["os-poll", "net"] } num_cpus = "1.13" -socket2 = "0.4.2" # TODO(MSRV 1.64) update to 0.5 +socket2 = "0.5" tokio = { version = "1.23.1", features = ["sync"] } tracing = { version = "0.1.30", default-features = false, features = ["log"] } diff --git a/actix-server/src/builder.rs b/actix-server/src/builder.rs index b6646081..badac77b 100644 --- a/actix-server/src/builder.rs +++ b/actix-server/src/builder.rs @@ -7,9 +7,7 @@ use tracing::{info, trace}; use crate::{ server::ServerCommand, service::{InternalServiceFactory, ServerServiceFactory, StreamNewService}, - socket::{ - create_mio_tcp_listener, MioListener, MioTcpListener, StdTcpListener, ToSocketAddrs, - }, + socket::{create_mio_tcp_listener, MioListener, MioTcpListener, StdTcpListener, ToSocketAddrs}, worker::ServerWorkerConfig, Server, }; @@ -246,8 +244,7 @@ impl ServerBuilder { use std::net::{IpAddr, Ipv4Addr}; lst.set_nonblocking(true)?; let token = self.next_token(); - let addr = - crate::socket::StdSocketAddr::new(IpAddr::V4(Ipv4Addr::new(127, 0, 0, 1)), 8080); + let addr = crate::socket::StdSocketAddr::new(IpAddr::V4(Ipv4Addr::new(127, 0, 0, 1)), 8080); self.factories.push(StreamNewService::create( name.as_ref().to_string(), token, diff --git a/actix-server/src/lib.rs b/actix-server/src/lib.rs index 532313b6..5e265d74 100644 --- a/actix-server/src/lib.rs +++ b/actix-server/src/lib.rs @@ -18,13 +18,12 @@ mod test_server; mod waker_queue; mod worker; -pub use self::builder::ServerBuilder; -pub use self::handle::ServerHandle; -pub use self::server::Server; -pub use self::service::ServerServiceFactory; #[doc(hidden)] pub use self::socket::FromStream; -pub use self::test_server::TestServer; +pub use self::{ + builder::ServerBuilder, handle::ServerHandle, server::Server, service::ServerServiceFactory, + test_server::TestServer, +}; /// Start server building process #[doc(hidden)] diff --git a/actix-server/src/service.rs b/actix-server/src/service.rs index f07ec3e5..eba1470e 100644 --- a/actix-server/src/service.rs +++ b/actix-server/src/service.rs @@ -78,7 +78,7 @@ where Ok(()) } Err(err) => { - error!("can not convert to an async TCP stream: {}", err); + error!("can not convert to an async TCP stream: {err}"); Err(()) } }) diff --git a/actix-server/src/socket.rs b/actix-server/src/socket.rs index 8d2ffe8f..f0942e38 100644 --- a/actix-server/src/socket.rs +++ b/actix-server/src/socket.rs @@ -8,8 +8,7 @@ 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, - std::os::unix::net::UnixListener as StdUnixListener, + mio::net::UnixListener as MioUnixListener, std::os::unix::net::UnixListener as StdUnixListener, }; pub(crate) enum MioListener { @@ -105,7 +104,7 @@ impl fmt::Debug for MioListener { fn fmt(&self, f: &mut fmt::Formatter<'_>) -> fmt::Result { match *self { MioListener::Tcp(ref lst) => write!(f, "{:?}", lst), - #[cfg(all(unix))] + #[cfg(unix)] MioListener::Uds(ref lst) => write!(f, "{:?}", lst), } } diff --git a/actix-server/src/worker.rs b/actix-server/src/worker.rs index 2765ae4a..a9ae97a0 100644 --- a/actix-server/src/worker.rs +++ b/actix-server/src/worker.rs @@ -625,8 +625,8 @@ impl Future for ServerWorker { let factory_id = restart.factory_id; let token = restart.token; - let (token_new, service) = ready!(restart.fut.as_mut().poll(cx)) - .unwrap_or_else(|_| { + let (token_new, service) = + ready!(restart.fut.as_mut().poll(cx)).unwrap_or_else(|_| { panic!( "Can not restart {:?} service", this.factories[factory_id].name(token) @@ -697,7 +697,10 @@ impl Future for ServerWorker { match ready!(this.conn_rx.poll_recv(cx)) { Some(msg) => { let guard = this.counter.guard(); - let _ = this.services[msg.token].service.call((guard, msg.io)); + let _ = this.services[msg.token] + .service + .call((guard, msg.io)) + .into_inner(); } None => return Poll::Ready(()), }; @@ -706,9 +709,7 @@ impl Future for ServerWorker { } } -fn wrap_worker_services( - services: Vec<(usize, usize, BoxedServerService)>, -) -> Vec { +fn wrap_worker_services(services: Vec<(usize, usize, BoxedServerService)>) -> Vec { services .into_iter() .fold(Vec::new(), |mut services, (idx, token, service)| { diff --git a/actix-service/CHANGES.md b/actix-service/CHANGES.md index 0640c1cd..ee549941 100644 --- a/actix-service/CHANGES.md +++ b/actix-service/CHANGES.md @@ -2,7 +2,7 @@ ## Unreleased - 2023-xx-xx -- Minimum supported Rust version (MSRV) is now 1.60. +- Minimum supported Rust version (MSRV) is now 1.65. ## 2.0.2 - 2021-12-18 diff --git a/actix-service/Cargo.toml b/actix-service/Cargo.toml index 74904634..dcb6652f 100644 --- a/actix-service/Cargo.toml +++ b/actix-service/Cargo.toml @@ -10,8 +10,8 @@ keywords = ["network", "framework", "async", "futures", "service"] categories = ["network-programming", "asynchronous", "no-std"] repository = "https://github.com/actix/actix-net" license = "MIT OR Apache-2.0" -edition = "2021" -rust-version = "1.60" +edition.workspace = true +rust-version.workspace = true [dependencies] futures-core = { version = "0.3.17", default-features = false } diff --git a/actix-service/src/and_then.rs b/actix-service/src/and_then.rs index 38980079..28a17044 100644 --- a/actix-service/src/and_then.rs +++ b/actix-service/src/and_then.rs @@ -121,12 +121,7 @@ pub struct AndThenServiceFactory where A: ServiceFactory, A::Config: Clone, - B: ServiceFactory< - A::Response, - Config = A::Config, - Error = A::Error, - InitError = A::InitError, - >, + B: ServiceFactory, { inner: Rc<(A, B)>, _phantom: PhantomData, @@ -136,12 +131,7 @@ impl AndThenServiceFactory where A: ServiceFactory, A::Config: Clone, - B: ServiceFactory< - A::Response, - Config = A::Config, - Error = A::Error, - InitError = A::InitError, - >, + B: ServiceFactory, { /// Create new `AndThenFactory` combinator pub(crate) fn new(a: A, b: B) -> Self { @@ -156,12 +146,7 @@ impl ServiceFactory for AndThenServiceFactory where A: ServiceFactory, A::Config: Clone, - B: ServiceFactory< - A::Response, - Config = A::Config, - Error = A::Error, - InitError = A::InitError, - >, + B: ServiceFactory, { type Response = B::Response; type Error = A::Error; @@ -184,12 +169,7 @@ impl Clone for AndThenServiceFactory where A: ServiceFactory, A::Config: Clone, - B: ServiceFactory< - A::Response, - Config = A::Config, - Error = A::Error, - InitError = A::InitError, - >, + B: ServiceFactory, { fn clone(&self) -> Self { Self { @@ -334,9 +314,8 @@ mod tests { async fn test_new_service() { let cnt = Rc::new(Cell::new(0)); let cnt2 = cnt.clone(); - let new_srv = - pipeline_factory(fn_factory(move || ready(Ok::<_, ()>(Srv1(cnt2.clone()))))) - .and_then(move || ready(Ok(Srv2(cnt.clone())))); + let new_srv = pipeline_factory(fn_factory(move || ready(Ok::<_, ()>(Srv1(cnt2.clone()))))) + .and_then(move || ready(Ok(Srv2(cnt.clone())))); let srv = new_srv.new_service(()).await.unwrap(); let res = srv.call("srv1").await; diff --git a/actix-service/src/apply.rs b/actix-service/src/apply.rs index c77f4242..d33bdcd8 100644 --- a/actix-service/src/apply.rs +++ b/actix-service/src/apply.rs @@ -140,8 +140,7 @@ where } } -impl ServiceFactory - for ApplyFactory +impl ServiceFactory for ApplyFactory where SF: ServiceFactory, F: Fn(Req, &SF::Service) -> Fut + Clone, diff --git a/actix-service/src/apply_cfg.rs b/actix-service/src/apply_cfg.rs index 25fc5fc2..028fb317 100644 --- a/actix-service/src/apply_cfg.rs +++ b/actix-service/src/apply_cfg.rs @@ -198,8 +198,7 @@ pin_project! { } } -impl Future - for ApplyConfigServiceFactoryResponse +impl Future for ApplyConfigServiceFactoryResponse where SF: ServiceFactory, SF::InitError: From, diff --git a/actix-service/src/boxed.rs b/actix-service/src/boxed.rs index 3141c5e4..cc9ad410 100644 --- a/actix-service/src/boxed.rs +++ b/actix-service/src/boxed.rs @@ -91,8 +91,7 @@ type Inner = Box< >, >; -impl ServiceFactory - for BoxServiceFactory +impl ServiceFactory for BoxServiceFactory where Req: 'static, Res: 'static, diff --git a/actix-service/src/fn_service.rs b/actix-service/src/fn_service.rs index a2379270..2dac8697 100644 --- a/actix-service/src/fn_service.rs +++ b/actix-service/src/fn_service.rs @@ -3,9 +3,7 @@ use core::{future::Future, marker::PhantomData}; use crate::{ok, IntoService, IntoServiceFactory, Ready, Service, ServiceFactory}; /// Create `ServiceFactory` for function that can act as a `Service` -pub fn fn_service( - f: F, -) -> FnServiceFactory +pub fn fn_service(f: F) -> FnServiceFactory where F: Fn(Req) -> Fut + Clone, Fut: Future>, @@ -48,9 +46,7 @@ where /// Ok(()) /// } /// ``` -pub fn fn_factory( - f: F, -) -> FnServiceNoConfig +pub fn fn_factory(f: F) -> FnServiceNoConfig where F: Fn() -> Fut, Fut: Future>, @@ -265,8 +261,7 @@ where } } -impl ServiceFactory - for FnServiceConfig +impl ServiceFactory for FnServiceConfig where F: Fn(Cfg) -> Fut, Fut: Future>, @@ -404,9 +399,8 @@ mod tests { ok::<_, Rc>(fn_service(|_: Rc| ok::<_, Rc>(Rc::new(0u8)))) }); - let fac_2 = fn_factory(|| { - ok::<_, Rc>(fn_service(|_: Rc| ok::<_, Rc>(Rc::new(0u8)))) - }); + let fac_2 = + fn_factory(|| ok::<_, Rc>(fn_service(|_: Rc| ok::<_, Rc>(Rc::new(0u8))))); fn is_send(_: &T) {} diff --git a/actix-service/src/lib.rs b/actix-service/src/lib.rs index 091a7fd7..fbbdfeb8 100644 --- a/actix-service/src/lib.rs +++ b/actix-service/src/lib.rs @@ -33,14 +33,16 @@ mod then; mod transform; mod transform_err; -pub use self::apply::{apply_fn, apply_fn_factory}; -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}; #[allow(unused_imports)] use self::ready::{err, ok, ready, Ready}; -pub use self::transform::{apply, ApplyTransform, Transform}; +pub use self::{ + apply::{apply_fn, apply_fn_factory}, + apply_cfg::{apply_cfg, apply_cfg_factory}, + ext::{ServiceExt, ServiceFactoryExt, TransformExt}, + fn_service::{fn_factory, fn_factory_with_config, fn_service}, + map_config::{map_config, unit_config}, + transform::{apply, ApplyTransform, Transform}, +}; /// An asynchronous operation from `Request` to a `Response`. /// diff --git a/actix-service/src/map_err.rs b/actix-service/src/map_err.rs index 3ce6f418..780a64c7 100644 --- a/actix-service/src/map_err.rs +++ b/actix-service/src/map_err.rs @@ -206,8 +206,7 @@ mod tests { use super::*; use crate::{ - err, ok, IntoServiceFactory, Ready, Service, ServiceExt, ServiceFactory, - ServiceFactoryExt, + err, ok, IntoServiceFactory, Ready, Service, ServiceExt, ServiceFactory, ServiceFactoryExt, }; struct Srv; diff --git a/actix-service/src/pipeline.rs b/actix-service/src/pipeline.rs index 2617d0ed..118f9797 100644 --- a/actix-service/src/pipeline.rs +++ b/actix-service/src/pipeline.rs @@ -6,12 +6,14 @@ use core::{ task::{Context, Poll}, }; -use crate::and_then::{AndThenService, AndThenServiceFactory}; -use crate::map::{Map, MapServiceFactory}; -use crate::map_err::{MapErr, MapErrServiceFactory}; -use crate::map_init_err::MapInitErr; -use crate::then::{ThenService, ThenServiceFactory}; -use crate::{IntoService, IntoServiceFactory, Service, ServiceFactory}; +use crate::{ + and_then::{AndThenService, AndThenServiceFactory}, + map::{Map, MapServiceFactory}, + map_err::{MapErr, MapErrServiceFactory}, + map_init_err::MapInitErr, + then::{ThenService, ThenServiceFactory}, + IntoService, IntoServiceFactory, Service, ServiceFactory, +}; /// Construct new pipeline with one service in pipeline chain. pub(crate) fn pipeline(service: I) -> Pipeline @@ -252,10 +254,7 @@ where } /// Map this service's error to a different error, returning a new service. - pub fn map_err( - self, - f: F, - ) -> PipelineFactory, Req> + pub fn map_err(self, f: F) -> PipelineFactory, Req> where Self: Sized, F: Fn(SF::Error) -> E + Clone, diff --git a/actix-tls/CHANGES.md b/actix-tls/CHANGES.md index f4f248b2..0381e6de 100644 --- a/actix-tls/CHANGES.md +++ b/actix-tls/CHANGES.md @@ -2,7 +2,7 @@ ## Unreleased - 2023-xx-xx -- Minimum supported Rust version (MSRV) is now 1.60. +- Minimum supported Rust version (MSRV) is now 1.65. ## 3.0.4 - 2022-03-15 diff --git a/actix-tls/Cargo.toml b/actix-tls/Cargo.toml index 9c463e2c..d65d675b 100755 --- a/actix-tls/Cargo.toml +++ b/actix-tls/Cargo.toml @@ -10,8 +10,8 @@ keywords = ["network", "tls", "ssl", "async", "transport"] repository = "https://github.com/actix/actix-net.git" categories = ["network-programming", "asynchronous", "cryptography"] license = "MIT OR Apache-2.0" -edition = "2021" -rust-version = "1.60" +edition.workspace = true +rust-version.workspace = true [package.metadata.docs.rs] all-features = true diff --git a/actix-tls/src/accept/mod.rs b/actix-tls/src/accept/mod.rs index 13c4db37..1eee6720 100644 --- a/actix-tls/src/accept/mod.rs +++ b/actix-tls/src/accept/mod.rs @@ -56,6 +56,25 @@ pub enum TlsError { Service(SvcErr), } +impl TlsError { + /// Casts the infallible service error type returned from acceptors into caller's type. + /// + /// # Examples + /// ``` + /// # use std::convert::Infallible; + /// # use actix_tls::accept::TlsError; + /// let a: TlsError = TlsError::Tls(42); + /// let _b: TlsError = a.into_service_error(); + /// ``` + pub fn into_service_error(self) -> TlsError { + match self { + Self::Timeout => TlsError::Timeout, + Self::Tls(err) => TlsError::Tls(err), + Self::Service(err) => match err {}, + } + } +} + impl fmt::Display for TlsError { fn fmt(&self, f: &mut fmt::Formatter<'_>) -> fmt::Result { match self { @@ -80,25 +99,6 @@ where } } -impl TlsError { - /// Casts the infallible service error type returned from acceptors into caller's type. - /// - /// # Examples - /// ``` - /// # use std::convert::Infallible; - /// # use actix_tls::accept::TlsError; - /// let a: TlsError = TlsError::Tls(42); - /// let _b: TlsError = a.into_service_error(); - /// ``` - pub fn into_service_error(self) -> TlsError { - match self { - Self::Timeout => TlsError::Timeout, - Self::Tls(err) => TlsError::Tls(err), - Self::Service(err) => match err {}, - } - } -} - #[cfg(test)] mod tests { use super::*; diff --git a/actix-tls/src/accept/rustls.rs b/actix-tls/src/accept/rustls.rs index bf324e3c..85cf5b00 100644 --- a/actix-tls/src/accept/rustls.rs +++ b/actix-tls/src/accept/rustls.rs @@ -23,8 +23,7 @@ use actix_utils::{ }; use pin_project_lite::pin_project; use tokio::io::{AsyncRead, AsyncWrite, ReadBuf}; -use tokio_rustls::rustls::ServerConfig; -use tokio_rustls::{Accept, TlsAcceptor}; +use tokio_rustls::{rustls::ServerConfig, Accept, TlsAcceptor}; use super::{TlsError, DEFAULT_TLS_HANDSHAKE_TIMEOUT, MAX_CONN_COUNTER}; diff --git a/actix-tls/src/connect/mod.rs b/actix-tls/src/connect/mod.rs index df002585..dae1f7b1 100644 --- a/actix-tls/src/connect/mod.rs +++ b/actix-tls/src/connect/mod.rs @@ -33,10 +33,12 @@ pub mod rustls; #[cfg(feature = "native-tls")] pub mod native_tls; -pub use self::connection::Connection; -pub use self::connector::{Connector, ConnectorService}; -pub use self::error::ConnectError; -pub use self::host::Host; -pub use self::info::ConnectInfo; -pub use self::resolve::Resolve; -pub use self::resolver::{Resolver, ResolverService}; +pub use self::{ + connection::Connection, + connector::{Connector, ConnectorService}, + error::ConnectError, + host::Host, + info::ConnectInfo, + resolve::Resolve, + resolver::{Resolver, ResolverService}, +}; diff --git a/actix-tls/src/connect/native_tls.rs b/actix-tls/src/connect/native_tls.rs index 37b9ffa4..16863ce0 100644 --- a/actix-tls/src/connect/native_tls.rs +++ b/actix-tls/src/connect/native_tls.rs @@ -19,8 +19,7 @@ use crate::connect::{Connection, Host}; 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; + pub use tokio_native_tls::{native_tls::TlsConnector, TlsStream as AsyncTlsStream}; } /// Connector service and factory using `native-tls`. diff --git a/actix-tls/src/connect/openssl.rs b/actix-tls/src/connect/openssl.rs index caff4f0f..ab2841bb 100644 --- a/actix-tls/src/connect/openssl.rs +++ b/actix-tls/src/connect/openssl.rs @@ -22,9 +22,7 @@ use crate::connect::{Connection, Host}; pub mod reexports { //! Re-exports from `openssl` and `tokio-openssl` that are useful for connectors. - pub use openssl::ssl::{ - Error, HandshakeError, SslConnector, SslConnectorBuilder, SslMethod, - }; + 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 0a44479a..5706047d 100644 --- a/actix-tls/src/connect/rustls.rs +++ b/actix-tls/src/connect/rustls.rs @@ -15,9 +15,11 @@ use actix_rt::net::ActixStream; use actix_service::{Service, ServiceFactory}; use actix_utils::future::{ok, Ready}; use futures_core::ready; -use tokio_rustls::rustls::{client::ServerName, OwnedTrustAnchor, RootCertStore}; -use tokio_rustls::{client::TlsStream as AsyncTlsStream, rustls::ClientConfig}; -use tokio_rustls::{Connect as RustlsConnect, TlsConnector as RustlsTlsConnector}; +use tokio_rustls::{ + client::TlsStream as AsyncTlsStream, + rustls::{client::ServerName, ClientConfig, OwnedTrustAnchor, RootCertStore}, + Connect as RustlsConnect, TlsConnector as RustlsTlsConnector, +}; use tracing::trace; use webpki_roots::TLS_SERVER_ROOTS; @@ -26,8 +28,7 @@ use crate::connect::{Connection, Host}; pub mod reexports { //! Re-exports from `rustls` and `webpki_roots` that are useful for connectors. - pub use tokio_rustls::client::TlsStream as AsyncTlsStream; - pub use tokio_rustls::rustls::ClientConfig; + pub use tokio_rustls::{client::TlsStream as AsyncTlsStream, 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 a4180f4d..ff707f65 100644 --- a/actix-tls/tests/accept-openssl.rs +++ b/actix-tls/tests/accept-openssl.rs @@ -17,11 +17,9 @@ use actix_utils::future::ok; use tokio_rustls::rustls::{Certificate, ClientConfig, RootCertStore, ServerName}; fn new_cert_and_key() -> (String, String) { - let cert = rcgen::generate_simple_self_signed(vec![ - "127.0.0.1".to_owned(), - "localhost".to_owned(), - ]) - .unwrap(); + let cert = + rcgen::generate_simple_self_signed(vec!["127.0.0.1".to_owned(), "localhost".to_owned()]) + .unwrap(); let key = cert.serialize_private_key_pem(); let cert = cert.serialize_pem().unwrap(); diff --git a/actix-tls/tests/accept-rustls.rs b/actix-tls/tests/accept-rustls.rs index 521af7f9..7955b36f 100644 --- a/actix-tls/tests/accept-rustls.rs +++ b/actix-tls/tests/accept-rustls.rs @@ -14,19 +14,19 @@ use std::io::{BufReader, Write}; use actix_rt::net::TcpStream; use actix_server::TestServer; use actix_service::ServiceFactoryExt as _; -use actix_tls::accept::rustls::{Acceptor, TlsStream}; -use actix_tls::connect::openssl::reexports::SslConnector; +use actix_tls::{ + accept::rustls::{Acceptor, TlsStream}, + connect::openssl::reexports::SslConnector, +}; use actix_utils::future::ok; use rustls_pemfile::{certs, pkcs8_private_keys}; use tls_openssl::ssl::SslVerifyMode; use tokio_rustls::rustls::{self, Certificate, PrivateKey, ServerConfig}; fn new_cert_and_key() -> (String, String) { - let cert = rcgen::generate_simple_self_signed(vec![ - "127.0.0.1".to_owned(), - "localhost".to_owned(), - ]) - .unwrap(); + let cert = + rcgen::generate_simple_self_signed(vec!["127.0.0.1".to_owned(), "localhost".to_owned()]) + .unwrap(); let key = cert.serialize_private_key_pem(); let cert = cert.serialize_pem().unwrap(); diff --git a/actix-tls/tests/test_resolvers.rs b/actix-tls/tests/test_resolvers.rs index f0674383..24f22732 100644 --- a/actix-tls/tests/test_resolvers.rs +++ b/actix-tls/tests/test_resolvers.rs @@ -51,8 +51,7 @@ async fn custom_resolver_connect() { use trust_dns_resolver::TokioAsyncResolver; - let srv = - TestServer::start(|| fn_service(|_io: TcpStream| async { Ok::<_, io::Error>(()) })); + let srv = TestServer::start(|| fn_service(|_io: TcpStream| async { Ok::<_, io::Error>(()) })); struct MyResolver { trust_dns: TokioAsyncResolver, diff --git a/actix-tracing/CHANGES.md b/actix-tracing/CHANGES.md index f672659a..f61d3f2b 100644 --- a/actix-tracing/CHANGES.md +++ b/actix-tracing/CHANGES.md @@ -2,7 +2,7 @@ ## Unreleased - 2023-xx-xx -- Minimum supported Rust version (MSRV) is now 1.60. +- Minimum supported Rust version (MSRV) is now 1.65. ## 0.1.0 - 2020-01-15 diff --git a/actix-tracing/Cargo.toml b/actix-tracing/Cargo.toml index 27dfbc22..829a4b85 100644 --- a/actix-tracing/Cargo.toml +++ b/actix-tracing/Cargo.toml @@ -9,8 +9,8 @@ repository = "https://github.com/actix/actix-net.git" documentation = "https://docs.rs/actix-tracing" categories = ["network-programming", "asynchronous"] license = "MIT OR Apache-2.0" -edition = "2021" -rust-version = "1.60" +edition.workspace = true +rust-version.workspace = true [dependencies] actix-service = "2" diff --git a/actix-tracing/src/lib.rs b/actix-tracing/src/lib.rs index f5b08927..b1b9061b 100644 --- a/actix-tracing/src/lib.rs +++ b/actix-tracing/src/lib.rs @@ -118,9 +118,11 @@ where #[cfg(test)] mod test { - use std::cell::RefCell; - use std::collections::{BTreeMap, BTreeSet}; - use std::sync::{Arc, RwLock}; + use std::{ + cell::RefCell, + collections::{BTreeMap, BTreeSet}, + sync::{Arc, RwLock}, + }; use actix_service::{fn_factory, fn_service}; use slab::Slab; diff --git a/actix-utils/CHANGES.md b/actix-utils/CHANGES.md index af6434ab..fc7df208 100644 --- a/actix-utils/CHANGES.md +++ b/actix-utils/CHANGES.md @@ -2,7 +2,7 @@ ## Unreleased - 2023-xx-xx -- Minimum supported Rust version (MSRV) is now 1.60. +- Minimum supported Rust version (MSRV) is now 1.65. ## 3.0.1 - 2022-10-21 diff --git a/actix-utils/Cargo.toml b/actix-utils/Cargo.toml index 38d8af5e..e3c2553f 100644 --- a/actix-utils/Cargo.toml +++ b/actix-utils/Cargo.toml @@ -10,8 +10,8 @@ keywords = ["network", "framework", "async", "futures"] categories = ["network-programming", "asynchronous"] repository = "https://github.com/actix/actix-net" license = "MIT OR Apache-2.0" -edition = "2021" -rust-version = "1.60" +edition.workspace = true +rust-version.workspace = true [dependencies] pin-project-lite = "0.2" diff --git a/actix-utils/src/future/mod.rs b/actix-utils/src/future/mod.rs index 399b54d2..ec87428d 100644 --- a/actix-utils/src/future/mod.rs +++ b/actix-utils/src/future/mod.rs @@ -4,6 +4,8 @@ mod either; mod poll_fn; mod ready; -pub use self::either::Either; -pub use self::poll_fn::{poll_fn, PollFn}; -pub use self::ready::{err, ok, ready, Ready}; +pub use self::{ + either::Either, + poll_fn::{poll_fn, PollFn}, + ready::{err, ok, ready, Ready}, +}; diff --git a/bytestring/Cargo.toml b/bytestring/Cargo.toml index 21da5a95..ab0e43c6 100644 --- a/bytestring/Cargo.toml +++ b/bytestring/Cargo.toml @@ -11,8 +11,8 @@ categories = ["no-std", "web-programming"] homepage = "https://actix.rs" repository = "https://github.com/actix/actix-net.git" license = "MIT OR Apache-2.0" -edition = "2021" -rust-version = "1.60" +edition.workspace = true +rust-version.workspace = true [dependencies] bytes = { version = "1.2", default-features = false } diff --git a/bytestring/src/lib.rs b/bytestring/src/lib.rs index 3892d09e..9c0007a2 100644 --- a/bytestring/src/lib.rs +++ b/bytestring/src/lib.rs @@ -253,8 +253,10 @@ impl fmt::Display for ByteString { mod serde { use alloc::string::String; - use serde::de::{Deserialize, Deserializer}; - use serde::ser::{Serialize, Serializer}; + use serde::{ + de::{Deserialize, Deserializer}, + ser::{Serialize, Serializer}, + }; use super::ByteString; diff --git a/local-channel/CHANGES.md b/local-channel/CHANGES.md index b1bad2f5..957adfd9 100644 --- a/local-channel/CHANGES.md +++ b/local-channel/CHANGES.md @@ -2,7 +2,7 @@ ## Unreleased - 2023-xx-xx -- Minimum supported Rust version (MSRV) is now 1.60. +- Minimum supported Rust version (MSRV) is now 1.65. ## 0.1.3 - 2022-05-03 diff --git a/local-channel/Cargo.toml b/local-channel/Cargo.toml index 04a4b9b5..9e0f21b4 100644 --- a/local-channel/Cargo.toml +++ b/local-channel/Cargo.toml @@ -9,8 +9,8 @@ authors = [ repository = "https://github.com/actix/actix-net.git" keywords = ["channel", "local", "futures"] license = "MIT OR Apache-2.0" -edition = "2021" -rust-version = "1.60" +edition.workspace = true +rust-version.workspace = true [dependencies] futures-core = "0.3.17" diff --git a/local-waker/CHANGES.md b/local-waker/CHANGES.md index 68f4348b..f8aadaa6 100644 --- a/local-waker/CHANGES.md +++ b/local-waker/CHANGES.md @@ -2,7 +2,7 @@ ## Unreleased - 2023-xx-xx -- Minimum supported Rust version (MSRV) is now 1.60. +- Minimum supported Rust version (MSRV) is now 1.65. ## 0.1.3 - 2022-05-03 diff --git a/local-waker/Cargo.toml b/local-waker/Cargo.toml index 1baa08c0..640c47e1 100644 --- a/local-waker/Cargo.toml +++ b/local-waker/Cargo.toml @@ -10,7 +10,7 @@ repository = "https://github.com/actix/actix-net.git" keywords = ["waker", "local", "futures", "no-std"] categories = ["asynchronous", "no-std"] license = "MIT OR Apache-2.0" -edition = "2021" -rust-version = "1.60" +edition.workspace = true +rust-version.workspace = true [dependencies] diff --git a/rustfmt.toml b/rustfmt.toml deleted file mode 100644 index a8758a07..00000000 --- a/rustfmt.toml +++ /dev/null @@ -1,2 +0,0 @@ -max_width = 96 -group_imports = "StdExternalCrate"