Re: [PATCH] rust: io: convert ResourceSize into a transparent newtype
From: Gary Guo
Date: Sun Jul 19 2026 - 16:54:15 EST
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