diff --git a/src/body/body.rs b/src/body/body.rs index a72a6fab95..44214757b8 100644 --- a/src/body/body.rs +++ b/src/body/body.rs @@ -41,7 +41,11 @@ enum Kind { content_length: Option, recv: h2::RecvStream, }, - Wrapped(Pin>> + Send>>), + // NOTE: This requires `Sync` because of how easy it is to use `await` + // while a borrow of a `Request` exists. + // + // See https://github.com/rust-lang/rust/issues/57017 + Wrapped(Pin>> + Send + Sync>>), } struct Extra { @@ -142,7 +146,7 @@ impl Body { /// ``` pub fn wrap_stream(stream: S) -> Body where - S: TryStream + Send + 'static, + S: TryStream + Send + Sync + 'static, S::Error: Into>, Chunk: From, { @@ -411,13 +415,13 @@ impl Stream for Body { impl - From>> + Send>> + From>> + Send + Sync>> for Body { #[inline] fn from( stream: Box< - dyn Stream>> + Send, + dyn Stream>> + Send + Sync, >, ) -> Body { Body::new(Kind::Wrapped(stream.into()))