Re: [PATCH v7 05/10] rust: io: add IoLoc and IoWrite types
From: Gary Guo
Date: Wed Mar 04 2026 - 15:05:23 EST
On Wed Mar 4, 2026 at 7:53 PM GMT, Danilo Krummrich wrote:
> On Wed Mar 4, 2026 at 8:19 PM CET, John Hubbard wrote:
>> I also want to register (haha) a strong yet unexplainable concern about
>> this. Registers as types is something I've never seen attempted, it feels
>> strange and unnecessary, and just worries me.
>
> Do you want to go back to lots of defines, manual masking and shifts rather than
> having a single obvious definition of a register that generates a type with
> getters and setters? Needless to say that the former is much more error prone
> and less readable. :)
Elimination of manual masking and shifts don't require a nominal type system :)
I can imagine use cases where a interrupt-enabled register and interrupt-pending
register has identical bitfields, and you might want to use the same type for
interrupt enabled and interrupt pending registers and might even want to use
bitwise operations between them :)
Ultimately bitfields types and register-as-types are all or nothing.
Best,
Gary