From e0e4d1e66124a8dfcc2259dc6c74f86159fbffb3 Mon Sep 17 00:00:00 2001 From: Rob Ede Date: Sun, 7 Jul 2024 03:54:00 +0100 Subject: [PATCH] chore: move deny lints to manifests --- Cargo.toml | 8 ++++++++ actix-files/Cargo.toml | 3 +++ actix-files/src/lib.rs | 3 +-- actix-http-test/Cargo.toml | 3 +++ actix-http-test/src/lib.rs | 2 -- actix-http/Cargo.toml | 3 +++ actix-http/src/h1/service.rs | 2 +- actix-http/src/h2/service.rs | 2 +- actix-http/src/lib.rs | 2 -- actix-http/src/message.rs | 2 +- actix-http/src/service.rs | 4 ++-- actix-http/src/test.rs | 4 ++-- actix-multipart-derive/Cargo.toml | 3 +++ actix-multipart-derive/src/lib.rs | 2 -- actix-multipart/Cargo.toml | 6 ++---- actix-router/Cargo.toml | 3 +++ actix-router/src/lib.rs | 2 -- actix-test/Cargo.toml | 3 +++ actix-test/src/lib.rs | 2 -- actix-web-actors/Cargo.toml | 3 +++ actix-web-actors/src/lib.rs | 2 -- actix-web-codegen/Cargo.toml | 3 +++ actix-web-codegen/src/lib.rs | 2 -- actix-web-codegen/tests/routes.rs | 2 +- actix-web-codegen/tests/scopes.rs | 2 +- actix-web/Cargo.toml | 3 +++ actix-web/src/app.rs | 2 +- actix-web/src/app_service.rs | 2 +- actix-web/src/config.rs | 4 ++-- actix-web/src/data.rs | 2 +- actix-web/src/lib.rs | 2 -- actix-web/src/middleware/default_headers.rs | 2 +- actix-web/src/middleware/err_handlers.rs | 16 ++++++++++------ actix-web/src/middleware/logger.rs | 2 +- actix-web/src/resource.rs | 6 +++--- actix-web/src/route.rs | 2 +- actix-web/src/server.rs | 18 +++++++++--------- awc/Cargo.toml | 3 +++ awc/src/client/pool.rs | 15 +++++++++------ awc/src/frozen.rs | 10 +++++----- awc/src/lib.rs | 2 -- awc/src/middleware/redirect.rs | 2 +- 42 files changed, 95 insertions(+), 71 deletions(-) diff --git a/Cargo.toml b/Cargo.toml index 19d5dd116..51f998314 100644 --- a/Cargo.toml +++ b/Cargo.toml @@ -51,3 +51,11 @@ awc = { path = "awc" } # actix-utils = { path = "../actix-net/actix-utils" } # actix-tls = { path = "../actix-net/actix-tls" } # actix-server = { path = "../actix-net/actix-server" } + +[workspace.lints.rust] +rust_2018_idioms = { level = "deny" } +future_incompatible = { level = "deny" } +nonstandard_style = { level = "deny" } + +[workspace.lints.clippy] +# clone_on_ref_ptr = { level = "deny" } diff --git a/actix-files/Cargo.toml b/actix-files/Cargo.toml index 57cd4e913..0c02359c4 100644 --- a/actix-files/Cargo.toml +++ b/actix-files/Cargo.toml @@ -54,3 +54,6 @@ actix-test = "0.1" actix-web = "4" env_logger = "0.11" tempfile = "3.2" + +[lints] +workspace = true diff --git a/actix-files/src/lib.rs b/actix-files/src/lib.rs index 0178c13de..551a14fa4 100644 --- a/actix-files/src/lib.rs +++ b/actix-files/src/lib.rs @@ -11,8 +11,7 @@ //! .service(Files::new("/static", ".").prefer_utf8(true)); //! ``` -#![deny(rust_2018_idioms, nonstandard_style)] -#![warn(future_incompatible, missing_docs, missing_debug_implementations)] +#![warn(missing_docs, missing_debug_implementations)] #![doc(html_logo_url = "https://actix.rs/img/logo.png")] #![doc(html_favicon_url = "https://actix.rs/favicon.ico")] #![cfg_attr(docsrs, feature(doc_auto_cfg))] diff --git a/actix-http-test/Cargo.toml b/actix-http-test/Cargo.toml index 0947579a5..7ccb70a45 100644 --- a/actix-http-test/Cargo.toml +++ b/actix-http-test/Cargo.toml @@ -59,3 +59,6 @@ tokio = { version = "1.24.2", features = ["sync"] } [dev-dependencies] actix-http = "3" + +[lints] +workspace = true diff --git a/actix-http-test/src/lib.rs b/actix-http-test/src/lib.rs index 554af9102..d83b0b3ea 100644 --- a/actix-http-test/src/lib.rs +++ b/actix-http-test/src/lib.rs @@ -1,7 +1,5 @@ //! Various helpers for Actix applications to use during testing. -#![deny(rust_2018_idioms, nonstandard_style)] -#![warn(future_incompatible)] #![doc(html_logo_url = "https://actix.rs/img/logo.png")] #![doc(html_favicon_url = "https://actix.rs/favicon.ico")] #![cfg_attr(docsrs, feature(doc_auto_cfg))] diff --git a/actix-http/Cargo.toml b/actix-http/Cargo.toml index 0a0252e9a..8fb31da4f 100644 --- a/actix-http/Cargo.toml +++ b/actix-http/Cargo.toml @@ -167,6 +167,9 @@ tls-openssl = { package = "openssl", version = "0.10.55" } tls-rustls_023 = { package = "rustls", version = "0.23" } tokio = { version = "1.24.2", features = ["net", "rt", "macros"] } +[lints] +workspace = true + [[example]] name = "ws" required-features = ["ws", "rustls-0_23"] diff --git a/actix-http/src/h1/service.rs b/actix-http/src/h1/service.rs index f2f8a0e48..4fbccf844 100644 --- a/actix-http/src/h1/service.rs +++ b/actix-http/src/h1/service.rs @@ -541,6 +541,6 @@ where fn call(&self, (io, addr): (T, Option)) -> Self::Future { let conn_data = OnConnectData::from_io(&io, self.on_connect_ext.as_deref()); - Dispatcher::new(io, self.flow.clone(), self.cfg.clone(), addr, conn_data) + Dispatcher::new(io, Rc::clone(&self.flow), self.cfg.clone(), addr, conn_data) } } diff --git a/actix-http/src/h2/service.rs b/actix-http/src/h2/service.rs index 636ac3161..debc73e59 100644 --- a/actix-http/src/h2/service.rs +++ b/actix-http/src/h2/service.rs @@ -434,7 +434,7 @@ where H2ServiceHandlerResponse { state: State::Handshake( - Some(self.flow.clone()), + Some(Rc::clone(&self.flow)), Some(self.cfg.clone()), addr, on_connect_data, diff --git a/actix-http/src/lib.rs b/actix-http/src/lib.rs index ac79433c6..734e6e1e1 100644 --- a/actix-http/src/lib.rs +++ b/actix-http/src/lib.rs @@ -20,8 +20,6 @@ //! [rustls]: https://crates.io/crates/rustls //! [trust-dns]: https://crates.io/crates/trust-dns -#![deny(rust_2018_idioms, nonstandard_style)] -#![warn(future_incompatible)] #![allow( clippy::type_complexity, clippy::too_many_arguments, diff --git a/actix-http/src/message.rs b/actix-http/src/message.rs index 47b128fd0..d2241b229 100644 --- a/actix-http/src/message.rs +++ b/actix-http/src/message.rs @@ -66,7 +66,7 @@ impl ops::DerefMut for Message { impl Drop for Message { fn drop(&mut self) { - T::with_pool(|p| p.release(self.head.clone())) + T::with_pool(|p| p.release(Rc::clone(&self.head))) } } diff --git a/actix-http/src/service.rs b/actix-http/src/service.rs index 37cee960f..3ea88274a 100644 --- a/actix-http/src/service.rs +++ b/actix-http/src/service.rs @@ -910,7 +910,7 @@ where handshake: Some(( crate::h2::handshake_with_timeout(io, &self.cfg), self.cfg.clone(), - self.flow.clone(), + Rc::clone(&self.flow), conn_data, peer_addr, )), @@ -926,7 +926,7 @@ where state: State::H1 { dispatcher: h1::Dispatcher::new( io, - self.flow.clone(), + Rc::clone(&self.flow), self.cfg.clone(), peer_addr, conn_data, diff --git a/actix-http/src/test.rs b/actix-http/src/test.rs index 3815e64c6..dfa9a86c9 100644 --- a/actix-http/src/test.rs +++ b/actix-http/src/test.rs @@ -159,8 +159,8 @@ impl TestBuffer { #[allow(dead_code)] pub(crate) fn clone(&self) -> Self { Self { - read_buf: self.read_buf.clone(), - write_buf: self.write_buf.clone(), + read_buf: Rc::clone(&self.read_buf), + write_buf: Rc::clone(&self.write_buf), err: self.err.clone(), } } diff --git a/actix-multipart-derive/Cargo.toml b/actix-multipart-derive/Cargo.toml index 33eacd460..964ef2b74 100644 --- a/actix-multipart-derive/Cargo.toml +++ b/actix-multipart-derive/Cargo.toml @@ -29,3 +29,6 @@ actix-multipart = "0.7" actix-web = "4" rustversion = "1" trybuild = "1" + +[lints] +workspace = true diff --git a/actix-multipart-derive/src/lib.rs b/actix-multipart-derive/src/lib.rs index 44db1fa0e..6818d477c 100644 --- a/actix-multipart-derive/src/lib.rs +++ b/actix-multipart-derive/src/lib.rs @@ -2,8 +2,6 @@ //! //! See [`macro@MultipartForm`] for usage examples. -#![deny(rust_2018_idioms, nonstandard_style)] -#![warn(future_incompatible)] #![doc(html_logo_url = "https://actix.rs/img/logo.png")] #![doc(html_favicon_url = "https://actix.rs/favicon.ico")] #![cfg_attr(docsrs, feature(doc_auto_cfg))] diff --git a/actix-multipart/Cargo.toml b/actix-multipart/Cargo.toml index e1172e8cf..a5b0e3a2c 100644 --- a/actix-multipart/Cargo.toml +++ b/actix-multipart/Cargo.toml @@ -71,7 +71,5 @@ multer = "3" tokio = { version = "1.24.2", features = ["sync"] } tokio-stream = "0.1" -[lints.rust] -future_incompatible = { level = "deny" } -rust_2018_idioms = { level = "deny" } -nonstandard_style = { level = "deny" } +[lints] +workspace = true diff --git a/actix-router/Cargo.toml b/actix-router/Cargo.toml index 7e7e3beb8..7def1bdb4 100644 --- a/actix-router/Cargo.toml +++ b/actix-router/Cargo.toml @@ -38,6 +38,9 @@ http = "0.2.7" serde = { version = "1", features = ["derive"] } percent-encoding = "2.1" +[lints] +workspace = true + [[bench]] name = "router" harness = false diff --git a/actix-router/src/lib.rs b/actix-router/src/lib.rs index c4d0d2c87..3f5e969e7 100644 --- a/actix-router/src/lib.rs +++ b/actix-router/src/lib.rs @@ -1,7 +1,5 @@ //! Resource path matching and router. -#![deny(rust_2018_idioms, nonstandard_style)] -#![warn(future_incompatible)] #![doc(html_logo_url = "https://actix.rs/img/logo.png")] #![doc(html_favicon_url = "https://actix.rs/favicon.ico")] #![cfg_attr(docsrs, feature(doc_auto_cfg))] diff --git a/actix-test/Cargo.toml b/actix-test/Cargo.toml index e810ae80b..34fdf2c82 100644 --- a/actix-test/Cargo.toml +++ b/actix-test/Cargo.toml @@ -73,3 +73,6 @@ tls-rustls-0_21 = { package = "rustls", version = "0.21", optional = true } tls-rustls-0_22 = { package = "rustls", version = "0.22", optional = true } tls-rustls-0_23 = { package = "rustls", version = "0.23", default-features = false, optional = true } tokio = { version = "1.24.2", features = ["sync"] } + +[lints] +workspace = true diff --git a/actix-test/src/lib.rs b/actix-test/src/lib.rs index 9be99978d..f0da2c20d 100644 --- a/actix-test/src/lib.rs +++ b/actix-test/src/lib.rs @@ -27,8 +27,6 @@ //! } //! ``` -#![deny(rust_2018_idioms, nonstandard_style)] -#![warn(future_incompatible)] #![doc(html_logo_url = "https://actix.rs/img/logo.png")] #![doc(html_favicon_url = "https://actix.rs/favicon.ico")] #![cfg_attr(docsrs, feature(doc_auto_cfg))] diff --git a/actix-web-actors/Cargo.toml b/actix-web-actors/Cargo.toml index 3c74a4f47..f753b7f7f 100644 --- a/actix-web-actors/Cargo.toml +++ b/actix-web-actors/Cargo.toml @@ -41,3 +41,6 @@ actix-web = { version = "4", features = ["macros"] } env_logger = "0.11" futures-util = { version = "0.3.17", default-features = false, features = ["std"] } mime = "0.3" + +[lints] +workspace = true diff --git a/actix-web-actors/src/lib.rs b/actix-web-actors/src/lib.rs index d89b0ee35..0198c830f 100644 --- a/actix-web-actors/src/lib.rs +++ b/actix-web-actors/src/lib.rs @@ -55,8 +55,6 @@ //! * [`HttpContext`]: This struct provides actor support for streaming HTTP responses. //! -#![deny(rust_2018_idioms, nonstandard_style)] -#![warn(future_incompatible)] #![doc(html_logo_url = "https://actix.rs/img/logo.png")] #![doc(html_favicon_url = "https://actix.rs/favicon.ico")] #![cfg_attr(docsrs, feature(doc_auto_cfg))] diff --git a/actix-web-codegen/Cargo.toml b/actix-web-codegen/Cargo.toml index 7500807d2..d3938da8e 100644 --- a/actix-web-codegen/Cargo.toml +++ b/actix-web-codegen/Cargo.toml @@ -35,3 +35,6 @@ actix-web = "4" futures-core = { version = "0.3.17", default-features = false, features = ["alloc"] } trybuild = "1" rustversion = "1" + +[lints] +workspace = true diff --git a/actix-web-codegen/src/lib.rs b/actix-web-codegen/src/lib.rs index c518007a0..e22bff8cd 100644 --- a/actix-web-codegen/src/lib.rs +++ b/actix-web-codegen/src/lib.rs @@ -73,8 +73,6 @@ //! [DELETE]: macro@delete #![recursion_limit = "512"] -#![deny(rust_2018_idioms, nonstandard_style)] -#![warn(future_incompatible)] #![doc(html_logo_url = "https://actix.rs/img/logo.png")] #![doc(html_favicon_url = "https://actix.rs/favicon.ico")] #![cfg_attr(docsrs, feature(doc_auto_cfg))] diff --git a/actix-web-codegen/tests/routes.rs b/actix-web-codegen/tests/routes.rs index fb50d4ae0..a6e606871 100644 --- a/actix-web-codegen/tests/routes.rs +++ b/actix-web-codegen/tests/routes.rs @@ -145,7 +145,7 @@ async fn custom_resource_name_test<'a>(req: HttpRequest) -> impl Responder { mod guard_module { use actix_web::{guard::GuardContext, http::header}; - pub fn guard(ctx: &GuardContext) -> bool { + pub fn guard(ctx: &GuardContext<'_>) -> bool { ctx.header::() .map(|h| h.preference() == "image/*") .unwrap_or(false) diff --git a/actix-web-codegen/tests/scopes.rs b/actix-web-codegen/tests/scopes.rs index 4ee6db16f..b8c832682 100644 --- a/actix-web-codegen/tests/scopes.rs +++ b/actix-web-codegen/tests/scopes.rs @@ -1,7 +1,7 @@ use actix_web::{guard::GuardContext, http, http::header, web, App, HttpResponse, Responder}; use actix_web_codegen::{delete, get, post, route, routes, scope}; -pub fn image_guard(ctx: &GuardContext) -> bool { +pub fn image_guard(ctx: &GuardContext<'_>) -> bool { ctx.header::() .map(|h| h.preference() == "image/*") .unwrap_or(false) diff --git a/actix-web/Cargo.toml b/actix-web/Cargo.toml index 125cfe20f..543f44400 100644 --- a/actix-web/Cargo.toml +++ b/actix-web/Cargo.toml @@ -188,6 +188,9 @@ tls-rustls = { package = "rustls", version = "0.23" } tokio = { version = "1.24.2", features = ["rt-multi-thread", "macros"] } zstd = "0.13" +[lints] +workspace = true + [[test]] name = "test_server" required-features = ["compress-brotli", "compress-gzip", "compress-zstd", "cookies"] diff --git a/actix-web/src/app.rs b/actix-web/src/app.rs index 21a4443cf..240e5b982 100644 --- a/actix-web/src/app.rs +++ b/actix-web/src/app.rs @@ -39,7 +39,7 @@ impl App { let factory_ref = Rc::new(RefCell::new(None)); App { - endpoint: AppEntry::new(factory_ref.clone()), + endpoint: AppEntry::new(Rc::clone(&factory_ref)), data_factories: Vec::new(), services: Vec::new(), default: None, diff --git a/actix-web/src/app_service.rs b/actix-web/src/app_service.rs index 65a6ed87b..7aa16b790 100644 --- a/actix-web/src/app_service.rs +++ b/actix-web/src/app_service.rs @@ -71,7 +71,7 @@ where }); // create App config to pass to child services - let mut config = AppService::new(config, default.clone()); + let mut config = AppService::new(config, Rc::clone(&default)); // register services mem::take(&mut *self.services.borrow_mut()) diff --git a/actix-web/src/config.rs b/actix-web/src/config.rs index 5e8b056f1..0e856f574 100644 --- a/actix-web/src/config.rs +++ b/actix-web/src/config.rs @@ -68,7 +68,7 @@ impl AppService { pub(crate) fn clone_config(&self) -> Self { AppService { config: self.config.clone(), - default: self.default.clone(), + default: Rc::clone(&self.default), services: Vec::new(), root: false, } @@ -81,7 +81,7 @@ impl AppService { /// Returns default handler factory. pub fn default_service(&self) -> Rc { - self.default.clone() + Rc::clone(&self.default) } /// Register HTTP service. diff --git a/actix-web/src/data.rs b/actix-web/src/data.rs index acbb8e23a..088df55d2 100644 --- a/actix-web/src/data.rs +++ b/actix-web/src/data.rs @@ -184,7 +184,7 @@ impl FromRequest for Data { impl DataFactory for Data { fn create(&self, extensions: &mut Extensions) -> bool { - extensions.insert(Data(self.0.clone())); + extensions.insert(Data(Arc::clone(&self.0))); true } } diff --git a/actix-web/src/lib.rs b/actix-web/src/lib.rs index 205391388..752852525 100644 --- a/actix-web/src/lib.rs +++ b/actix-web/src/lib.rs @@ -70,8 +70,6 @@ //! - `rustls-0_23` - HTTPS support via `rustls` 0.23 crate, supports `HTTP/2` //! - `secure-cookies` - secure cookies support -#![deny(rust_2018_idioms, nonstandard_style)] -#![warn(future_incompatible)] #![doc(html_logo_url = "https://actix.rs/img/logo.png")] #![doc(html_favicon_url = "https://actix.rs/favicon.ico")] #![cfg_attr(docsrs, feature(doc_auto_cfg))] diff --git a/actix-web/src/middleware/default_headers.rs b/actix-web/src/middleware/default_headers.rs index f21afe6eb..2669a047e 100644 --- a/actix-web/src/middleware/default_headers.rs +++ b/actix-web/src/middleware/default_headers.rs @@ -141,7 +141,7 @@ where actix_service::forward_ready!(service); fn call(&self, req: ServiceRequest) -> Self::Future { - let inner = self.inner.clone(); + let inner = Rc::clone(&self.inner); let fut = self.service.call(req); DefaultHeaderFuture { diff --git a/actix-web/src/middleware/err_handlers.rs b/actix-web/src/middleware/err_handlers.rs index aa6d1c8a4..3c50d5c8f 100644 --- a/actix-web/src/middleware/err_handlers.rs +++ b/actix-web/src/middleware/err_handlers.rs @@ -220,16 +220,20 @@ impl ErrorHandlers { /// [`.handler()`][ErrorHandlers::handler]) will fall back on this. /// /// Note that this will overwrite any default handlers previously set by calling - /// [`.default_handler_client()`][ErrorHandlers::default_handler_client] or - /// [`.default_handler_server()`][ErrorHandlers::default_handler_server], but not any set by - /// calling [`.handler()`][ErrorHandlers::handler]. + /// [`default_handler_client()`] or [`.default_handler_server()`], but not any set by calling + /// [`.handler()`]. + /// + /// [`default_handler_client()`]: ErrorHandlers::default_handler_client + /// [`.default_handler_server()`]: ErrorHandlers::default_handler_server + /// [`.handler()`]: ErrorHandlers::handler pub fn default_handler(self, handler: F) -> Self where F: Fn(ServiceResponse) -> Result> + 'static, { let handler = Rc::new(handler); + let handler2 = Rc::clone(&handler); Self { - default_server: Some(handler.clone()), + default_server: Some(handler2), default_client: Some(handler), ..self } @@ -288,7 +292,7 @@ where type Future = LocalBoxFuture<'static, Result>; fn new_transform(&self, service: S) -> Self::Future { - let handlers = self.handlers.clone(); + let handlers = Rc::clone(&self.handlers); let default_client = self.default_client.clone(); let default_server = self.default_server.clone(); Box::pin(async move { @@ -323,7 +327,7 @@ where actix_service::forward_ready!(service); fn call(&self, req: ServiceRequest) -> Self::Future { - let handlers = self.handlers.clone(); + let handlers = Rc::clone(&self.handlers); let default_client = self.default_client.clone(); let default_server = self.default_server.clone(); let fut = self.service.call(req); diff --git a/actix-web/src/middleware/logger.rs b/actix-web/src/middleware/logger.rs index dc1b02399..e9ac24d50 100644 --- a/actix-web/src/middleware/logger.rs +++ b/actix-web/src/middleware/logger.rs @@ -276,7 +276,7 @@ where ready(Ok(LoggerMiddleware { service, - inner: self.0.clone(), + inner: Rc::clone(&self.0), })) } } diff --git a/actix-web/src/resource.rs b/actix-web/src/resource.rs index 00555b7b2..d89438edb 100644 --- a/actix-web/src/resource.rs +++ b/actix-web/src/resource.rs @@ -62,14 +62,14 @@ pub struct Resource { impl Resource { /// Constructs new resource that matches a `path` pattern. pub fn new(path: T) -> Resource { - let fref = Rc::new(RefCell::new(None)); + let factory_ref = Rc::new(RefCell::new(None)); Resource { routes: Vec::new(), rdef: path.patterns(), name: None, - endpoint: ResourceEndpoint::new(fref.clone()), - factory_ref: fref, + endpoint: ResourceEndpoint::new(Rc::clone(&factory_ref)), + factory_ref, guards: Vec::new(), app_data: None, default: boxed::factory(fn_service(|req: ServiceRequest| async { diff --git a/actix-web/src/route.rs b/actix-web/src/route.rs index 261e6b9ae..e05e6be52 100644 --- a/actix-web/src/route.rs +++ b/actix-web/src/route.rs @@ -77,7 +77,7 @@ impl ServiceFactory for Route { fn new_service(&self, _: ()) -> Self::Future { let fut = self.service.new_service(()); - let guards = self.guards.clone(); + let guards = Rc::clone(&self.guards); Box::pin(async move { let service = fut.await?; diff --git a/actix-web/src/server.rs b/actix-web/src/server.rs index 95e15581f..d8519fb9e 100644 --- a/actix-web/src/server.rs +++ b/actix-web/src/server.rs @@ -510,7 +510,7 @@ where /// No changes are made to `lst`'s configuration. Ensure it is configured properly before /// passing ownership to `listen()`. pub fn listen(mut self, lst: net::TcpListener) -> io::Result { - let cfg = self.config.clone(); + let cfg = Arc::clone(&self.config); let factory = self.factory.clone(); let addr = lst.local_addr().unwrap(); @@ -554,7 +554,7 @@ where /// Binds to existing listener for accepting incoming plaintext HTTP/1.x or HTTP/2 connections. #[cfg(feature = "http2")] pub fn listen_auto_h2c(mut self, lst: net::TcpListener) -> io::Result { - let cfg = self.config.clone(); + let cfg = Arc::clone(&self.config); let factory = self.factory.clone(); let addr = lst.local_addr().unwrap(); @@ -632,7 +632,7 @@ where config: actix_tls::accept::rustls_0_20::reexports::ServerConfig, ) -> io::Result { let factory = self.factory.clone(); - let cfg = self.config.clone(); + let cfg = Arc::clone(&self.config); let addr = lst.local_addr().unwrap(); self.sockets.push(Socket { addr, @@ -683,7 +683,7 @@ where config: actix_tls::accept::rustls_0_21::reexports::ServerConfig, ) -> io::Result { let factory = self.factory.clone(); - let cfg = self.config.clone(); + let cfg = Arc::clone(&self.config); let addr = lst.local_addr().unwrap(); self.sockets.push(Socket { addr, @@ -749,7 +749,7 @@ where config: actix_tls::accept::rustls_0_22::reexports::ServerConfig, ) -> io::Result { let factory = self.factory.clone(); - let cfg = self.config.clone(); + let cfg = Arc::clone(&self.config); let addr = lst.local_addr().unwrap(); self.sockets.push(Socket { addr, @@ -815,7 +815,7 @@ where config: actix_tls::accept::rustls_0_23::reexports::ServerConfig, ) -> io::Result { let factory = self.factory.clone(); - let cfg = self.config.clone(); + let cfg = Arc::clone(&self.config); let addr = lst.local_addr().unwrap(); self.sockets.push(Socket { addr, @@ -880,7 +880,7 @@ where acceptor: SslAcceptor, ) -> io::Result { let factory = self.factory.clone(); - let cfg = self.config.clone(); + let cfg = Arc::clone(&self.config); let addr = lst.local_addr().unwrap(); self.sockets.push(Socket { addr, @@ -937,7 +937,7 @@ where use actix_rt::net::UnixStream; use actix_service::{fn_service, ServiceFactoryExt as _}; - let cfg = self.config.clone(); + let cfg = Arc::clone(&self.config); let factory = self.factory.clone(); let socket_addr = net::SocketAddr::new(net::IpAddr::V4(net::Ipv4Addr::new(127, 0, 0, 1)), 8080); @@ -982,7 +982,7 @@ where use actix_rt::net::UnixStream; use actix_service::{fn_service, ServiceFactoryExt as _}; - let cfg = self.config.clone(); + let cfg = Arc::clone(&self.config); let factory = self.factory.clone(); let socket_addr = net::SocketAddr::new(net::IpAddr::V4(net::Ipv4Addr::new(127, 0, 0, 1)), 8080); diff --git a/awc/Cargo.toml b/awc/Cargo.toml index 4fc2057f6..353ca0d54 100644 --- a/awc/Cargo.toml +++ b/awc/Cargo.toml @@ -153,6 +153,9 @@ tokio = { version = "1.24.2", features = ["rt-multi-thread", "macros"] } zstd = "0.13" tls-rustls-0_23 = { package = "rustls", version = "0.23" } # add rustls 0.23 with default features to make aws_lc_rs work in tests +[lints] +workspace = true + [[example]] name = "client" required-features = ["rustls-0_23-webpki-roots"] diff --git a/awc/src/client/pool.rs b/awc/src/client/pool.rs index 2938353fd..4c439e4eb 100644 --- a/awc/src/client/pool.rs +++ b/awc/src/client/pool.rs @@ -173,12 +173,15 @@ where }; // acquire an owned permit and carry it with connection - let permit = inner.permits.clone().acquire_owned().await.map_err(|_| { - ConnectError::Io(io::Error::new( - io::ErrorKind::Other, - "failed to acquire semaphore on client connection pool", - )) - })?; + let permit = Arc::clone(&inner.permits) + .acquire_owned() + .await + .map_err(|_| { + ConnectError::Io(io::Error::new( + io::ErrorKind::Other, + "failed to acquire semaphore on client connection pool", + )) + })?; let conn = { let mut conn = None; diff --git a/awc/src/frozen.rs b/awc/src/frozen.rs index 8f3244997..90b2c6efd 100644 --- a/awc/src/frozen.rs +++ b/awc/src/frozen.rs @@ -49,7 +49,7 @@ impl FrozenClientRequest { where B: MessageBody + 'static, { - RequestSender::Rc(self.head.clone(), None).send_body( + RequestSender::Rc(Rc::clone(&self.head), None).send_body( self.addr, self.response_decompress, self.timeout, @@ -60,7 +60,7 @@ impl FrozenClientRequest { /// Send a json body. pub fn send_json(&self, value: &T) -> SendClientRequest { - RequestSender::Rc(self.head.clone(), None).send_json( + RequestSender::Rc(Rc::clone(&self.head), None).send_json( self.addr, self.response_decompress, self.timeout, @@ -71,7 +71,7 @@ impl FrozenClientRequest { /// Send an urlencoded body. pub fn send_form(&self, value: &T) -> SendClientRequest { - RequestSender::Rc(self.head.clone(), None).send_form( + RequestSender::Rc(Rc::clone(&self.head), None).send_form( self.addr, self.response_decompress, self.timeout, @@ -86,7 +86,7 @@ impl FrozenClientRequest { S: Stream> + 'static, E: Into + 'static, { - RequestSender::Rc(self.head.clone(), None).send_stream( + RequestSender::Rc(Rc::clone(&self.head), None).send_stream( self.addr, self.response_decompress, self.timeout, @@ -97,7 +97,7 @@ impl FrozenClientRequest { /// Send an empty body. pub fn send(&self) -> SendClientRequest { - RequestSender::Rc(self.head.clone(), None).send( + RequestSender::Rc(Rc::clone(&self.head), None).send( self.addr, self.response_decompress, self.timeout, diff --git a/awc/src/lib.rs b/awc/src/lib.rs index 460480994..b582d51e4 100644 --- a/awc/src/lib.rs +++ b/awc/src/lib.rs @@ -100,8 +100,6 @@ //! # } //! ``` -#![deny(rust_2018_idioms, nonstandard_style)] -#![warn(future_incompatible)] #![allow(unknown_lints)] // temp: #[allow(non_local_definitions)] #![allow( clippy::type_complexity, diff --git a/awc/src/middleware/redirect.rs b/awc/src/middleware/redirect.rs index 0ea5f174e..b2cf9c45b 100644 --- a/awc/src/middleware/redirect.rs +++ b/awc/src/middleware/redirect.rs @@ -78,7 +78,7 @@ where RedirectServiceFuture::Tunnel { fut } } ConnectRequest::Client(head, body, addr) => { - let connector = self.connector.clone(); + let connector = Rc::clone(&self.connector); let max_redirect_times = self.max_redirect_times; // backup the uri and method for reuse schema and authority.