From: Alice Ryhl <aliceryhl@google.com>
To: Benno Lossin <lossin@kernel.org>
Cc: "Alexandre Courbot" <acourbot@nvidia.com>,
"Miguel Ojeda" <ojeda@kernel.org>,
"Boqun Feng" <boqun.feng@gmail.com>,
"Gary Guo" <gary@garyguo.net>,
"Björn Roy Baron" <bjorn3_gh@protonmail.com>,
"Andreas Hindborg" <a.hindborg@kernel.org>,
"Trevor Gross" <tmgross@umich.edu>,
"Danilo Krummrich" <dakr@kernel.org>,
"John Hubbard" <jhubbard@nvidia.com>,
"Alistair Popple" <apopple@nvidia.com>,
"Joel Fernandes" <joelagnelf@nvidia.com>,
"Timur Tabi" <ttabi@nvidia.com>, "Edwin Peer" <epeer@nvidia.com>,
"Eliot Courtney" <ecourtney@nvidia.com>,
rust-for-linux@vger.kernel.org, linux-kernel@vger.kernel.org
Subject: Re: [PATCH v3 1/2] rust: transmute: implement FromBytes and AsBytes for inhabited ZSTs
Date: Thu, 11 Dec 2025 01:21:33 +0000 [thread overview]
Message-ID: <aTocnf23EBdU3tFV@google.com> (raw)
In-Reply-To: <DETOEHE7WBR8.2440Z49KZTAY@kernel.org>
On Tue, Dec 09, 2025 at 01:14:08PM +0100, Benno Lossin wrote:
> On Tue Dec 9, 2025 at 3:57 AM CET, Alexandre Courbot wrote:
> > This is useful when using types that may or may not be empty in generic
> > code relying on these traits. It is also safe because technically a
> > no-op.
> >
> > Reviewed-by: Alistair Popple <apopple@nvidia.com>
> > Signed-off-by: Alexandre Courbot <acourbot@nvidia.com>
> > ---
> > rust/kernel/transmute.rs | 8 ++++++++
> > 1 file changed, 8 insertions(+)
> >
> > diff --git a/rust/kernel/transmute.rs b/rust/kernel/transmute.rs
> > index be5dbf3829e2..a888a312e7ff 100644
> > --- a/rust/kernel/transmute.rs
> > +++ b/rust/kernel/transmute.rs
> > @@ -170,6 +170,10 @@ macro_rules! impl_frombytes {
> > }
> >
> > impl_frombytes! {
> > + // SAFETY: Inhabited ZSTs only have one possible bit pattern.
>
> Even inhabited ZSTs cannot just be conjured out of thin air, since there
> might be safety invariants on the creation of such a type. Now these
> two concrete ones do not have any, so this is fine, but should still be
> mentioned in the comment IMO.
I think we can say "it has no invariants".
Alice
next prev parent reply other threads:[~2025-12-11 1:21 UTC|newest]
Thread overview: 6+ messages / expand[flat|nested] mbox.gz Atom feed top
2025-12-09 2:57 [PATCH v3 0/2] rust: transmute: implement FromBytes and AsBytes for inhabited ZSTs Alexandre Courbot
2025-12-09 2:57 ` [PATCH v3 1/2] " Alexandre Courbot
2025-12-09 12:14 ` Benno Lossin
2025-12-11 1:21 ` Alice Ryhl [this message]
2025-12-09 2:58 ` [PATCH v3 2/2] gpu: nova-core: gsp: use () as message type for GspInitDone message Alexandre Courbot
2025-12-09 12:18 ` [PATCH v3 0/2] rust: transmute: implement FromBytes and AsBytes for inhabited ZSTs Gary Guo
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=aTocnf23EBdU3tFV@google.com \
--to=aliceryhl@google.com \
--cc=a.hindborg@kernel.org \
--cc=acourbot@nvidia.com \
--cc=apopple@nvidia.com \
--cc=bjorn3_gh@protonmail.com \
--cc=boqun.feng@gmail.com \
--cc=dakr@kernel.org \
--cc=ecourtney@nvidia.com \
--cc=epeer@nvidia.com \
--cc=gary@garyguo.net \
--cc=jhubbard@nvidia.com \
--cc=joelagnelf@nvidia.com \
--cc=linux-kernel@vger.kernel.org \
--cc=lossin@kernel.org \
--cc=ojeda@kernel.org \
--cc=rust-for-linux@vger.kernel.org \
--cc=tmgross@umich.edu \
--cc=ttabi@nvidia.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 a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for NNTP newsgroup(s).