[<prev] [next>] [<thread-prev] [day] [month] [year] [list]
Message-ID: <a6a0a98e-d2b5-4245-b146-d2268b471e4f@gmail.com>
Date: Fri, 30 Jan 2026 06:36:48 -0300
From: Filipe Xavier <felipeaggger@...il.com>
To: Miguel Ojeda <miguel.ojeda.sandonis@...il.com>
Cc: Miguel Ojeda <ojeda@...nel.org>, Alex Gaynor <alex.gaynor@...il.com>,
Boqun Feng <boqun.feng@...il.com>, Gary Guo <gary@...yguo.net>,
Björn Roy Baron <bjorn3_gh@...tonmail.com>,
Benno Lossin <benno.lossin@...ton.me>,
Andreas Hindborg <a.hindborg@...nel.org>, Alice Ryhl <aliceryhl@...gle.com>,
Trevor Gross <tmgross@...ch.edu>, Danilo Krummrich <dakr@...nel.org>,
daniel.almeida@...labora.com, rust-for-linux@...r.kernel.org,
felipe_life@...e.com, linux-kernel@...r.kernel.org,
Lyude Paul <lyude@...hat.com>
Subject: Re: [PATCH v9] rust: add new macro for common bitflag operations
On 1/30/26 2:25 AM, Miguel Ojeda wrote:
> On Sat, Jan 17, 2026 at 11:41 AM Filipe Xavier <felipeaggger@...il.com> wrote:
>> We have seen a proliferation of mod_whatever::foo::Flags
>> being defined with essentially the same implementation
>> for BitAnd, BitOr, contains and etc.
>>
>> This macro aims to bring a solution for this,
>> allowing to generate these methods for user-defined structs.
>> With some use cases in KMS and upcoming GPU drivers.
>>
>> Link: https://rust-for-linux.zulipchat.com/#narrow/channel/288089-General/topic/We.20really.20need.20a.20common.20.60Flags.60.20type
>> Suggested-by: Daniel Almeida <daniel.almeida@...labora.com>
>> Suggested-by: Lyude Paul <lyude@...hat.com>
>> Reviewed-by: Daniel Almeida <daniel.almeida@...labora.com>
>> Reviewed-by: Lyude Paul <lyude@...hat.com>
>> Tested-by: Andreas Hindborg <a.hindborg@...nel.org>
>> Reviewed-by: Andreas Hindborg <a.hindborg@...nel.org>
>> Signed-off-by: Filipe Xavier <felipeaggger@...il.com>
> So I was about to apply this one and I noticed a few bits (no need for
> a new version):
>
> - This was added to the prelude -- I asked the team and they felt it
> wasn't needed, so I will remove it. We can always add it later on if
> needed.
Sounds good, no problem.
>
> - Is `BitXorAssign<$flag> for $flags` missing for some reason? I will add:
>
> impl ::core::ops::BitXorAssign<$flag> for $flags {
> #[inline]
> fn bitxor_assign(&mut self, rhs: $flag) {
> *self = *self ^ rhs;
> }
> }
>
> This is why I like to have tests for every operator... I may open
> a good first issue about it :)
Regarding |BitXorAssign|, that was indeed an oversight on my part.
Adding it makes perfect sense.
> I also fixed an intra-doc link and tweaked a couple other bits.
Thanks for the review and for taking the time with this.
Xavier
> Cheers,
> Miguel
Powered by blists - more mailing lists