diff --git a/src/ffi/task.rs b/src/ffi/task.rs index f53a7b1f5a..e745710633 100644 --- a/src/ffi/task.rs +++ b/src/ffi/task.rs @@ -127,6 +127,7 @@ struct TaskFuture { /// its only purpose is to provide access to the waker. See `hyper_waker`. /// /// Corresponding Rust type: +#[repr(C)] // we transmute references pub struct hyper_context<'a>(Context<'a>); /// A waker that is saved and used to waken a pending task. @@ -500,7 +501,7 @@ where impl hyper_context<'_> { pub(crate) fn wrap<'a, 'b>(cx: &'a mut Context<'b>) -> &'a mut hyper_context<'b> { - // A struct with only one field has the same layout as that field. + // A repr(C) newtype has the same layout as its only field. unsafe { std::mem::transmute::<&mut Context<'_>, &mut hyper_context<'_>>(cx) } } } diff --git a/src/proto/h2/mod.rs b/src/proto/h2/mod.rs index 15afe48d23..66879aa6c8 100644 --- a/src/proto/h2/mod.rs +++ b/src/proto/h2/mod.rs @@ -386,6 +386,7 @@ fn h2_to_io_error(e: h2::Error) -> std::io::Error { } } +#[repr(transparent)] struct UpgradedSendStream(SendStream>>); impl UpgradedSendStream