From: "Gary Guo" <gary@garyguo.net>
To: "Alexandre Courbot" <acourbot@nvidia.com>,
"Yilin Chen" <1479826151@qq.com>
Cc: <gary@garyguo.net>, <rust-for-linux@vger.kernel.org>,
<linux-kernel@vger.kernel.org>, <yury.norov@gmail.com>,
<ojeda@kernel.org>
Subject: Re: [PATCH v2] rust: bitfield: require integer storage
Date: Tue, 22 Sep 2026 15:02:51 +0100 [thread overview]
Message-ID: <DLLWG2N3ZTPY.1YC2GW2DGGEH8@garyguo.net> (raw)
In-Reply-To: <DLLW8NY8GF79.3U3VGJF2C3Z63@nvidia.com>
On Tue Sep 22, 2026 at 2:53 PM BST, Alexandre Courbot wrote:
>>
>> - // SAFETY: `$storage` is `Zeroable` and `$name` is transparent.
>> - unsafe impl ::pin_init::Zeroable for $name {}
>> + // SAFETY:
>> + // - `$storage: Integer` is sealed to primitive integer types, for which the all-zero bit
>> + // pattern is valid.
>> + // - `$name` is `repr(transparent)` over `$storage`.
>> + unsafe impl ::pin_init::Zeroable for $name
>> + where $storage: ::kernel::num::Integer
>> + {}
>
> While I guess that would somehow work, I think the proper place to do
> this is the struct definition, i.e:
>
> $vis struct $name
> where
> $storage: $crate::num::Integer,
> {
> inner: $storage,
> }
>
> This makes the error message also more explicit about what the problem
> is (a bitfield requires an `Integer`, not merely the ability to
> initialize it to zero).
Agreed.
Best,
Gary
next prev parent reply other threads:[~2026-09-22 14:02 UTC|newest]
Thread overview: 9+ messages / expand[flat|nested] mbox.gz Atom feed top
2026-09-13 15:34 [PATCH] rust: bitfield: require Zeroable storage for Zeroable impl Yilin Chen
2026-09-13 19:37 ` Gary Guo
2026-09-21 6:32 ` Yilin Chen
2026-09-21 7:18 ` Alexandre Courbot
2026-09-21 10:05 ` Gary Guo
2026-09-22 5:28 ` [PATCH v2] rust: bitfield: require integer storage Yilin Chen
2026-09-22 13:53 ` Alexandre Courbot
2026-09-22 14:02 ` Gary Guo [this message]
2026-09-22 13:39 ` [PATCH] rust: bitfield: require Zeroable storage for Zeroable impl Alexandre Courbot
Reply instructions:
You may reply publicly to this message via plain-text email
using any one of the following methods:
* Save the following mbox file, import it into your mail client,
and reply-to-all from there: mbox
Avoid top-posting and favor interleaved quoting:
https://en.wikipedia.org/wiki/Posting_style#Interleaved_style
* Reply using the --to, --cc, and --in-reply-to
switches of git-send-email(1):
git send-email \
--in-reply-to=DLLWG2N3ZTPY.1YC2GW2DGGEH8@garyguo.net \
--to=gary@garyguo.net \
--cc=1479826151@qq.com \
--cc=acourbot@nvidia.com \
--cc=linux-kernel@vger.kernel.org \
--cc=ojeda@kernel.org \
--cc=rust-for-linux@vger.kernel.org \
--cc=yury.norov@gmail.com \
/path/to/YOUR_REPLY
https://kernel.org/pub/software/scm/git/docs/git-send-email.html
* If your mail client supports setting the In-Reply-To header
via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line
before the message body.
This is an external index of several public inboxes,
see mirroring instructions on how to clone and mirror
all data and code used by this external index.