Re: [PATCH] rust: iommu: replace core::mem::zeroed with pin_init::zeroed
From: Nicolás Antinori
Date: Mon Jun 29 2026 - 15:50:02 EST
On Sun Jun 28, 2026 at 7:31 AM -03, Miguel Ojeda wrote:
> On Sat, Jun 27, 2026 at 10:35 AM Alexandre Courbot <acourbot@xxxxxxxxxx> wrote:
>>
>> Note that you can also use `..Zeroable::zeroed()` here since we are not
>> in const context. Not sure which one we prefer in this case, but I'd
>> personally err on the side of not referring to `pin_init` unless we are
>> dealing with a pinned object or need to because of a const requirement.
>
> That sounds reasonable -- Benno/Gary, any comments?
>
> By the way, speaking of that: the docs of `zeroed()` (both of them)
> could mention the existence of the other (and the `const fn`
> difference).
If it is ok, I can send a patch modifying the doc comments to link both
functions, noting that the const version should be used in const
contexts/pinned objects and that `Zeroable::zeroed()` should be
preferred when possible (as Gary commented in [1]).
I'll send a v2 with `..Zeroable::zeroed()` shortly.
Thank you all for the comments!
[1] https://lore.kernel.org/rust-for-linux/DJKV3IQ0SXA1.30T5Y71AL6KV7@xxxxxxxxxxx/