Skip to content

Commit e64d8da

Browse files
committed
Add repr(transparent) to hyper_context
1 parent 1d4ff35 commit e64d8da

File tree

2 files changed

+3
-1
lines changed

2 files changed

+3
-1
lines changed

src/ffi/task.rs

+2-1
Original file line numberDiff line numberDiff line change
@@ -127,6 +127,7 @@ struct TaskFuture {
127127
/// its only purpose is to provide access to the waker. See `hyper_waker`.
128128
///
129129
/// Corresponding Rust type: <https://doc.rust-lang.org/std/task/struct.Context.html>
130+
#[repr(transparent)] // we transmute references
130131
pub struct hyper_context<'a>(Context<'a>);
131132

132133
/// A waker that is saved and used to waken a pending task.
@@ -500,7 +501,7 @@ where
500501

501502
impl hyper_context<'_> {
502503
pub(crate) fn wrap<'a, 'b>(cx: &'a mut Context<'b>) -> &'a mut hyper_context<'b> {
503-
// A struct with only one field has the same layout as that field.
504+
// A repr(transparent) struct has the same layout its dataful field.
504505
unsafe { std::mem::transmute::<&mut Context<'_>, &mut hyper_context<'_>>(cx) }
505506
}
506507
}

src/proto/h2/mod.rs

+1
Original file line numberDiff line numberDiff line change
@@ -386,6 +386,7 @@ fn h2_to_io_error(e: h2::Error) -> std::io::Error {
386386
}
387387
}
388388

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

391392
impl<B> UpgradedSendStream<B>

0 commit comments

Comments
 (0)