Re: [PATCH 1/3] rust: sync: implement == operator for ARef
From: Alice Ryhl
Date: Thu Feb 19 2026 - 09:37:48 EST
On Thu, Feb 19, 2026 at 02:27:38PM +0000, Gary Guo wrote:
> On 2026-02-19 13:52, Alice Ryhl wrote:
> > Rust Binder wants to perform a comparison between ARef<Task> and &Task,
> > so define the == operator for ARef<_> when compared with another ARef<_>
> > or just a reference. The operator is implemented in terms of the same
> > operator applied to the inner type.
> >
> > Signed-off-by: Alice Ryhl <aliceryhl@xxxxxxxxxx>
>
> I suppose `PartialEq<U>` cannot be implemented due to trait coherence issue?
That's right:
error[E0119]: conflicting implementations of trait `core::cmp::PartialEq<sync::aref::ARef<_>>` for type `sync::aref::ARef<_>`
--> /usr/local/google/home/aliceryhl/devel/linux/rust/kernel/sync/aref.rs:185:1
|
174 | / impl<T, U> PartialEq<ARef<U>> for ARef<T>
175 | | where
176 | | T: AlwaysRefCounted + PartialEq<U>,
177 | | U: AlwaysRefCounted,
| |________________________- first implementation here
...
185 | / impl<T, U> PartialEq<U> for ARef<T>
186 | | where
187 | | T: AlwaysRefCounted + PartialEq<U>,
| |_______________________________________^ conflicting implementation for `sync::aref::ARef<_>`
I can mention this in commit msg if I send another version.
> Reviewed-by: Gary Guo <gary@xxxxxxxxxxx>
Thanks!