Skip to content

Commit 293df63

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

File tree

1 file changed

+2
-1
lines changed

1 file changed

+2
-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
}

0 commit comments

Comments
 (0)