Re: [PATCH] rust: iommu: replace core::mem::zeroed with pin_init::zeroed

Nicolás Antinori <[email protected]> Mon, 29 Jun 2026 16:45:53 -0300
Newsgroups dev.linux.lists.linux-kernel-mentees,dev.linux.lists.iommu,org.kernel.vger.linux-kernel,org.kernel.vger.rust-for-linux
Message-ID <[email protected]>
On Sun Jun 28, 2026 at 7:31 AM -03, Miguel Ojeda wrote:
> On Sat, Jun 27, 2026 at 10:35 AM Alexandre Courbot <[email protected]> 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/[email protected]/