From b5812b15f07271850367b085e4933a0989dd84f9 Mon Sep 17 00:00:00 2001 From: PeterUlb Date: Tue, 29 Sep 2020 23:44:12 +0200 Subject: [PATCH 1/3] Remove Sized Bound for web::Data (#1712) --- CHANGES.md | 1 + src/data.rs | 32 ++++++++++++++++++++++++++------ 2 files changed, 27 insertions(+), 6 deletions(-) diff --git a/CHANGES.md b/CHANGES.md index 3419ce818..86e022409 100644 --- a/CHANGES.md +++ b/CHANGES.md @@ -5,6 +5,7 @@ * Add `TrailingSlash::MergeOnly` behaviour to `NormalizePath`, which allow `NormalizePath` to keep the trailing slash's existance as it is. [#1695] * Fix `ResourceMap` recursive references when printing/debugging. [#1708] +* Remove bound `std::marker::Sized` from `web::Data` to support storing `Arc` via `web::Data::from` [#1710] [#1708]: https://github.com/actix/actix-web/pull/1708 diff --git a/src/data.rs b/src/data.rs index c50b30328..6405fd901 100644 --- a/src/data.rs +++ b/src/data.rs @@ -66,7 +66,7 @@ pub(crate) type FnDataFactory = /// } /// ``` #[derive(Debug)] -pub struct Data(Arc); +pub struct Data(Arc); impl Data { /// Create new `Data` instance. @@ -89,7 +89,7 @@ impl Data { } } -impl Deref for Data { +impl Deref for Data { type Target = Arc; fn deref(&self) -> &Arc { @@ -97,19 +97,19 @@ impl Deref for Data { } } -impl Clone for Data { +impl Clone for Data { fn clone(&self) -> Data { Data(self.0.clone()) } } -impl From> for Data { +impl From> for Data { fn from(arc: Arc) -> Self { Data(arc) } } -impl FromRequest for Data { +impl FromRequest for Data { type Config = (); type Error = Error; type Future = Ready>; @@ -131,7 +131,7 @@ impl FromRequest for Data { } } -impl DataFactory for Data { +impl DataFactory for Data { fn create(&self, extensions: &mut Extensions) -> bool { if !extensions.contains::>() { extensions.insert(Data(self.0.clone())); @@ -293,4 +293,24 @@ mod tests { let data_from_arc = Data::from(Arc::new(String::from("test-123"))); assert_eq!(data_new.0, data_from_arc.0) } + + #[actix_rt::test] + async fn test_data_from_dyn_arc() { + trait TestTrait { + fn get_num(&self) -> i32; + } + struct A {} + impl TestTrait for A { + fn get_num(&self) -> i32 { + 42 + } + } + // This works when Sized is required + let dyn_arc_box: Arc> = Arc::new(Box::new(A {})); + let data_arc_box = Data::from(dyn_arc_box); + // This works when Data Sized Bound is removed + let dyn_arc: Arc = Arc::new(A {}); + let data_arc = Data::from(dyn_arc); + assert_eq!(data_arc_box.get_num(), data_arc.get_num()) + } } From aa11231ee5285016e7d326c834ba061401ac511d Mon Sep 17 00:00:00 2001 From: Rob Ede Date: Wed, 30 Sep 2020 11:07:35 +0100 Subject: [PATCH 2/3] prepare web release 3.1.0 (#1716) --- CHANGES.md | 25 +++++++++++++++++-------- Cargo.toml | 2 +- actix-web-codegen/CHANGES.md | 23 ++++++++++++----------- 3 files changed, 30 insertions(+), 20 deletions(-) diff --git a/CHANGES.md b/CHANGES.md index 86e022409..5fd3869f9 100644 --- a/CHANGES.md +++ b/CHANGES.md @@ -1,13 +1,22 @@ # Changes ## Unreleased - 2020-xx-xx -### Changed -* Add `TrailingSlash::MergeOnly` behaviour to `NormalizePath`, which allow `NormalizePath` - to keep the trailing slash's existance as it is. [#1695] -* Fix `ResourceMap` recursive references when printing/debugging. [#1708] -* Remove bound `std::marker::Sized` from `web::Data` to support storing `Arc` via `web::Data::from` [#1710] + +## 3.1.0 - 2020-09-29 +### Changed +* Add `TrailingSlash::MergeOnly` behaviour to `NormalizePath`, which allows `NormalizePath` + to retain any trailing slashes. [#1695] +* Remove bound `std::marker::Sized` from `web::Data` to support storing `Arc` + via `web::Data::from` [#1710] + +### Fixed +* `ResourceMap` debug printing is no longer infinitely recursive. [#1708] + +[#1695]: https://github.com/actix/actix-web/pull/1695 [#1708]: https://github.com/actix/actix-web/pull/1708 +[#1710]: https://github.com/actix/actix-web/pull/1710 + ## 3.0.2 - 2020-09-15 ### Fixed @@ -177,7 +186,7 @@ ### Deleted -* Delete HttpServer::run(), it is not useful witht async/await +* Delete HttpServer::run(), it is not useful with async/await ## [2.0.0-alpha.3] - 2019-12-07 @@ -222,7 +231,7 @@ ### Changed -* Make UrlEncodedError::Overflow more informativve +* Make UrlEncodedError::Overflow more informative * Use actix-testing for testing utils @@ -240,7 +249,7 @@ * Re-implement Host predicate (#989) -* Form immplements Responder, returning a `application/x-www-form-urlencoded` response +* Form implements Responder, returning a `application/x-www-form-urlencoded` response * Add `into_inner` to `Data` diff --git a/Cargo.toml b/Cargo.toml index d4da4af11..56158389c 100644 --- a/Cargo.toml +++ b/Cargo.toml @@ -1,6 +1,6 @@ [package] name = "actix-web" -version = "3.0.2" +version = "3.1.0" authors = ["Nikolay Kim "] description = "Actix web is a powerful, pragmatic, and extremely fast web framework for Rust." readme = "README.md" diff --git a/actix-web-codegen/CHANGES.md b/actix-web-codegen/CHANGES.md index ad1a22b88..1ab51f924 100644 --- a/actix-web-codegen/CHANGES.md +++ b/actix-web-codegen/CHANGES.md @@ -5,7 +5,7 @@ ## 0.4.0 - 2020-09-20 * Added compile success and failure testing. [#1677] -* Add `route` macro for supporting multiple HTTP methods guards. +* Add `route` macro for supporting multiple HTTP methods guards. [#1674] [#1677]: https://github.com/actix/actix-web/pull/1677 [#1674]: https://github.com/actix/actix-web/pull/1674 @@ -21,47 +21,48 @@ [#1559]: https://github.com/actix/actix-web/pull/1559 -## [0.2.2] - 2020-05-23 +## 0.2.2 - 2020-05-23 * Add resource middleware on actix-web-codegen [#1467] [#1467]: https://github.com/actix/actix-web/pull/1467 -## [0.2.1] - 2020-02-25 + +## 0.2.1 - 2020-02-25 * Add `#[allow(missing_docs)]` attribute to generated structs [#1368] * Allow the handler function to be named as `config` [#1290] [#1368]: https://github.com/actix/actix-web/issues/1368 [#1290]: https://github.com/actix/actix-web/issues/1290 -## [0.2.0] - 2019-12-13 +## 0.2.0 - 2019-12-13 * Generate code for actix-web 2.0 -## [0.1.3] - 2019-10-14 +## 0.1.3 - 2019-10-14 * Bump up `syn` & `quote` to 1.0 * Provide better error message -## [0.1.2] - 2019-06-04 +## 0.1.2 - 2019-06-04 * Add macros for head, options, trace, connect and patch http methods -## [0.1.1] - 2019-06-01 +## 0.1.1 - 2019-06-01 * Add syn "extra-traits" feature -## [0.1.0] - 2019-05-18 +## 0.1.0 - 2019-05-18 * Release -## [0.1.0-beta.1] - 2019-04-20 +## 0.1.0-beta.1 - 2019-04-20 * Gen code for actix-web 1.0.0-beta.1 -## [0.1.0-alpha.6] - 2019-04-14 +## 0.1.0-alpha.6 - 2019-04-14 * Gen code for actix-web 1.0.0-alpha.6 -## [0.1.0-alpha.1] - 2019-03-28 +## 0.1.0-alpha.1 - 2019-03-28 * Initial impl From c2c71cc6269fa5a432a51e2802be5f2327d7633a Mon Sep 17 00:00:00 2001 From: Yuki Okushi Date: Thu, 1 Oct 2020 18:19:09 +0900 Subject: [PATCH 3/3] Fix/suppress clippy warnings (#1720) --- actix-http/src/lib.rs | 1 + src/lib.rs | 1 + src/scope.rs | 1 - src/types/json.rs | 2 +- src/types/payload.rs | 2 +- 5 files changed, 4 insertions(+), 3 deletions(-) diff --git a/actix-http/src/lib.rs b/actix-http/src/lib.rs index b52e8179c..fab91be2b 100644 --- a/actix-http/src/lib.rs +++ b/actix-http/src/lib.rs @@ -7,6 +7,7 @@ clippy::new_without_default, clippy::borrow_interior_mutable_const )] +#![allow(clippy::manual_strip)] // Allow this to keep MSRV(1.42). #[macro_use] extern crate log; diff --git a/src/lib.rs b/src/lib.rs index 327cba954..edc8456ba 100644 --- a/src/lib.rs +++ b/src/lib.rs @@ -67,6 +67,7 @@ #![deny(rust_2018_idioms)] #![allow(clippy::needless_doctest_main, clippy::type_complexity)] +#![allow(clippy::rc_buffer)] // FXIME: We should take a closer look for the warnings at some point. #![doc(html_logo_url = "https://actix.rs/img/logo.png")] #![doc(html_favicon_url = "https://actix.rs/favicon.ico")] diff --git a/src/scope.rs b/src/scope.rs index 25b5366d8..2520fd7ae 100644 --- a/src/scope.rs +++ b/src/scope.rs @@ -58,7 +58,6 @@ type BoxedResponse = LocalBoxFuture<'static, Result>; /// * /{project_id}/path1 - responds to all http method /// * /{project_id}/path2 - `GET` requests /// * /{project_id}/path3 - `HEAD` requests -/// pub struct Scope { endpoint: T, rdef: String, diff --git a/src/types/json.rs b/src/types/json.rs index 8da5a3bdb..081a022e8 100644 --- a/src/types/json.rs +++ b/src/types/json.rs @@ -283,7 +283,7 @@ impl JsonConfig { fn from_req(req: &HttpRequest) -> &Self { req.app_data::() .or_else(|| req.app_data::>().map(|d| d.as_ref())) - .unwrap_or_else(|| &DEFAULT_CONFIG) + .unwrap_or(&DEFAULT_CONFIG) } } diff --git a/src/types/payload.rs b/src/types/payload.rs index bbdd89525..4ff5ef4b4 100644 --- a/src/types/payload.rs +++ b/src/types/payload.rs @@ -284,7 +284,7 @@ impl PayloadConfig { fn from_req(req: &HttpRequest) -> &Self { req.app_data::() .or_else(|| req.app_data::>().map(|d| d.as_ref())) - .unwrap_or_else(|| &DEFAULT_CONFIG) + .unwrap_or(&DEFAULT_CONFIG) } }