From 199c238d3dd0263718b0aa804ecea5a4bcb0b6d4 Mon Sep 17 00:00:00 2001 From: Sean McArthur Date: Wed, 15 Nov 2023 11:09:59 -0500 Subject: [PATCH 1/4] deps: update http to 1.0 --- http-body-util/Cargo.toml | 2 +- http-body/Cargo.toml | 2 +- 2 files changed, 2 insertions(+), 2 deletions(-) diff --git a/http-body-util/Cargo.toml b/http-body-util/Cargo.toml index 5b2e21e..7a803b9 100644 --- a/http-body-util/Cargo.toml +++ b/http-body-util/Cargo.toml @@ -28,7 +28,7 @@ categories = ["web-programming"] [dependencies] bytes = "1" futures-util = { version = "0.3.14", default-features = false, features = ["alloc"] } -http = "0.2" +http = "1" http-body = { version = "=1.0.0-rc.2", path = "../http-body" } pin-project-lite = "0.2" diff --git a/http-body/Cargo.toml b/http-body/Cargo.toml index ab0faf1..09a032e 100644 --- a/http-body/Cargo.toml +++ b/http-body/Cargo.toml @@ -26,4 +26,4 @@ categories = ["web-programming"] [dependencies] bytes = "1" -http = "0.2" +http = "1" From 26f0d20ad64525a0986b3d7468732eb5ee708cd5 Mon Sep 17 00:00:00 2001 From: Sean McArthur Date: Wed, 15 Nov 2023 11:16:26 -0500 Subject: [PATCH 2/4] clippy: document unsafe pin projection --- http-body/src/lib.rs | 4 ++++ 1 file changed, 4 insertions(+) diff --git a/http-body/src/lib.rs b/http-body/src/lib.rs index 81acdaa..12077a2 100644 --- a/http-body/src/lib.rs +++ b/http-body/src/lib.rs @@ -141,6 +141,8 @@ impl Body for http::Request { self: Pin<&mut Self>, cx: &mut Context<'_>, ) -> Poll, Self::Error>>> { + // SAFETY: + // A pin projection. unsafe { self.map_unchecked_mut(http::Request::body_mut) .poll_frame(cx) @@ -164,6 +166,8 @@ impl Body for http::Response { self: Pin<&mut Self>, cx: &mut Context<'_>, ) -> Poll, Self::Error>>> { + // SAFETY: + // A pin projection. unsafe { self.map_unchecked_mut(http::Response::body_mut) .poll_frame(cx) From e925f31a87b212557385c1e39e98e2b8d3f9d22c Mon Sep 17 00:00:00 2001 From: Sean McArthur Date: Wed, 15 Nov 2023 11:19:59 -0500 Subject: [PATCH 3/4] clippy: fix up into_iter and clone-on-copy --- http-body-util/src/collected.rs | 2 +- http-body-util/src/empty.rs | 4 +--- 2 files changed, 2 insertions(+), 4 deletions(-) diff --git a/http-body-util/src/collected.rs b/http-body-util/src/collected.rs index 20df2cd..31a02a4 100644 --- a/http-body-util/src/collected.rs +++ b/http-body-util/src/collected.rs @@ -53,7 +53,7 @@ impl Collected { if let Ok(trailers) = frame.into_trailers() { if let Some(current) = &mut self.trailers { - current.extend(trailers.into_iter()); + current.extend(trailers); } else { self.trailers = Some(trailers); } diff --git a/http-body-util/src/empty.rs b/http-body-util/src/empty.rs index 0c6adea..d1445b4 100644 --- a/http-body-util/src/empty.rs +++ b/http-body-util/src/empty.rs @@ -57,9 +57,7 @@ impl Default for Empty { impl Clone for Empty { fn clone(&self) -> Self { - Self { - _marker: PhantomData, - } + *self } } From 335f48e8cb7ec2dd9b683f95c8db9dd02ab87e05 Mon Sep 17 00:00:00 2001 From: Sean McArthur Date: Wed, 15 Nov 2023 11:22:17 -0500 Subject: [PATCH 4/4] clippy: assert is_none --- http-body-util/src/limited.rs | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/http-body-util/src/limited.rs b/http-body-util/src/limited.rs index 239c46c..c4c5c8b 100644 --- a/http-body-util/src/limited.rs +++ b/http-body-util/src/limited.rs @@ -122,7 +122,7 @@ mod tests { hint.set_upper(0); assert_eq!(body.size_hint().upper(), hint.upper()); - assert!(matches!(body.frame().await, None)); + assert!(body.frame().await.is_none()); } #[tokio::test] @@ -207,7 +207,7 @@ mod tests { hint.set_upper(0); assert_eq!(body.size_hint().upper(), hint.upper()); - assert!(matches!(body.frame().await, None)); + assert!(body.frame().await.is_none()); } struct SomeTrailers;