Re: [RFC PATCH 0/2] rust: bounded integer types and use in register macro

From: Joel Fernandes
Date: Wed Oct 01 2025 - 18:09:28 EST


Hi Alex,

Nice!

On 10/1/2025 11:03 AM, Alexandre Courbot wrote:
> For convenience, this PoC is based on drm-rust-next. If we decide to
> proceed with it, we would do it after the patchset extracting and moving
> the bitfield logic [3] lands, as the two would conflict heavily.

I would strongly prefer this as well, to avoid conflicts. On initial look, this
seems to be in the right direction and solves the pain points we were seeing.

- .set_sec(if sec { 1 } else { 0 });
+ .set_sec_bounded(BoundedInt::new(if sec { 1 } else { 0 }));

Here, I would prefer if we did not add _bounded, since the idea is to solve the
problems in the macro's setters itself (make it infallible, not panicking etc).
So we can just modify those?

Also, BoundedInt sounds like a good name to me IMO.

Also, since TryFrom trait is implemented in the first patch, then in nova we can
just do the following?
.set_foo(value.try_into()?);

That's slightly simpler to read than:
.set_foo(BoundedInt::try_from(value)?);

And closer to the old syntax of
.set_foo(value); // used to truncate

But I don't feel strongly about not using the full form version.

thanks,

- Joel