Re: [PATCH] rust: io: convert ResourceSize into a transparent newtype

"Gary Guo" <[email protected]>
Newsgroups dev.linux.lists.driver-core,dev.linux.lists.nova-gpu,org.freedesktop.lists.dri-devel,org.kernel.vger.linux-kernel,org.kernel.vger.rust-for-linux
Message-ID <[email protected]>
On Sun Jul 19, 2026 at 3:53 PM BST, Danilo Krummrich wrote:
> On Sun Jul 19, 2026 at 12:40 PM CEST, Lorenzo Delgado wrote:
>> I tried that, but it doesn't build. ResourceSize wraps resource_size_t,
>> which is u64 on 64-bit (CONFIG_PHYS_ADDR_T_64BIT), so the impl the patch
>> already has,
>>
>>     impl From<ResourceSize> for bindings::resource_size_t
>>
>> is already From<ResourceSize> for u64 there, and a second one conflicts:
>>
>>     error[E0119]: conflicting implementations of trait
>>                   `From<ResourceSize>` for type `u64`
>
> Sure, but in the case a cfg-gate is perfectly fine, as the impl will always be
> availble.  Either through impl for u64 directly or through impl for
> bindings::resource_size_t.

Given that `resource_size_t` is either u32 or u64 depending on cfg, essentially
`From<ResourceSize> for bindings::resource_size_t` has cfg-gating. So basically
we always unconditionally have u64 impl, and for `!CONFIG_PHYS_ADDR_T_64BIT` we
have a condition u32 impl.

Best,
Gary
lmpx.com only provides a reader for public news (NNTP) servers. It is not affiliated with the servers or forums shown here and is not responsible for the content of articles, which is written by their respective authors.