Re: [PATCH] rust: bitfield: add conversions to Bounded of matching width
From: Alexandre Courbot
Date: Thu Dec 03 2026 - 21:04:25 EST
On Wed Dec 2, 2026 at 10:39 PM JST, Gary Guo wrote:
> On Wed Dec 2, 2026 at 12:21 AM GMT, Alexandre Courbot wrote:
>> On Wed Dec 2, 2026 at 6:18 AM JST, Miguel Ojeda wrote:
>>> On Fri, 27 Nov 2026 21:05:40 +0900 Alexandre Courbot <acourbot@xxxxxxxxxx> wrote:
>>>>
>>>> `From`/`Into` implementations already exist between a bitfield type and
>>>> its storage type, but these are not enough to support nested bitfields,
>>>> since every field is a `Bounded`. This resulted in some ad-hoc
>>>> implementations to enable this kind of declaration:
>>>>
>>>> bitfield! {
>>>> pub struct Version(u8) {
>>>> 7:4 major;
>>>> 3:0 minor;
>>>> }
>>>> }
>>>>
>>>> bitfield! {
>>>> pub struct Id(u16) {
>>>> 15:8 vendor;
>>>> 7:0 version => Version;
>>>> }
>>>> }
>>>>
>>>> Generate these conversions automatically through the `bitfield!` macro,
>>>> as these tend to be useful.
>>>>
>>>> Tyr had such ad-hoc implementations, so remove them to avoid conflicts.
>>>>
>>>> Signed-off-by: Alexandre Courbot <acourbot@xxxxxxxxxx>
>>>
>>> Applied to `rust-next` -- thanks everyone!
>>
>> Note that this is going to create a merge conflict with `drm-rust-next`,
>> some of the Tyr code has been updated concurrently. It's a single one
>> though, and taking "theirs" should solve it, so more trivial than I
>> expected.
>>
>> Which makes me think, there are more patches affecting `num` than I
>> initially expected, would it help if I maintained a tree and sent you
>> PRs, timed to avoid such conflicts when possible?
>
> Do you expect continued traffic on `num`, or it'd quiet down a bit once the
> features are there and users are converted?
Unexpected features seem to keep getting added, but I cannot predict
what the future flow will be. The module is general enough (all things
numeric) that we can expect it to grow further imho.
My proposal is in the interest of making things more efficient/less time
consuming for upstream Rust maintainers, but if the current flow is
deemed to be fine then that works for me as well.