Skip to content

Commit

Permalink
Add repr(transparent) to hyper_context
Browse files Browse the repository at this point in the history
  • Loading branch information
Manishearth committed Dec 20, 2023
1 parent 1d4ff35 commit 3d73180
Show file tree
Hide file tree
Showing 2 changed files with 3 additions and 1 deletion.
3 changes: 2 additions & 1 deletion src/ffi/task.rs
Expand Up @@ -127,6 +127,7 @@ struct TaskFuture {
/// its only purpose is to provide access to the waker. See `hyper_waker`.
///
/// Corresponding Rust type: <https://doc.rust-lang.org/std/task/struct.Context.html>
#[repr(packed)] // we transmute references
pub struct hyper_context<'a>(Context<'a>);

/// A waker that is saved and used to waken a pending task.
Expand Down Expand Up @@ -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(packed) newtype has the same layout as its only field.
unsafe { std::mem::transmute::<&mut Context<'_>, &mut hyper_context<'_>>(cx) }
}
}
Expand Down
1 change: 1 addition & 0 deletions src/proto/h2/mod.rs
Expand Up @@ -386,6 +386,7 @@ fn h2_to_io_error(e: h2::Error) -> std::io::Error {
}
}

#[repr(transparent)]
struct UpgradedSendStream<B>(SendStream<SendBuf<Neutered<B>>>);

impl<B> UpgradedSendStream<B>
Expand Down

0 comments on commit 3d73180

Please sign in to comment.