Re: [PATCH 6/6] rust: hrtimer: Make HrTimer repr(transparent)
From: Andreas Hindborg
Date: Wed Aug 26 2026 - 05:34:23 EST
"Gary Guo" <gary@xxxxxxxxxxx> writes:
> On Tue Aug 25, 2026 at 1:16 PM BST, Andreas Hindborg wrote:
>> From: FUJITA Tomonori <fujita.tomonori@xxxxxxxxx>
>>
>> HrTimerCallbackContext acquires a &HrTimer<T> from a
>> NonNull<HrTimer<T>> while a &mut HrTimer<T> can exist at the same
>> time. This is sound only because HrTimer's sole field is
>> Opaque<bindings::hrtimer>, which puts every byte behind an UnsafeCell.
>> Adding a field to HrTimer that is not Opaque would make acquiring that
>> shared reference unsound.
>
> HrTimerCallbackContext is removed in patch 4, though?
>
> Still worh preferring `#[repr(transparent)]` over `#[repr(C)]`, but the
> motivation should be reworded and the comment on `HrTimer` should be removed.
Yes, I was a little too fast when I added this patch. I'd like to keep
it as well, but it needs some edits.
Best regards,
Andreas Hindborg