Skip to content

Commit f010ccd

Browse files
RuoqingHeroypat
authored andcommitted
fam: Remove PartialEq trait constraint on Entry
Some of the `FAM` structs that exist in the kernel (and which we hence deal with in `kvm-bindings`) have `Entry`s that are union. But `bindgen` doesn't derive `PartialEq` for unions, and so trying to actually declare the FamStructWrapper type for those means we'd need to painfully handwrite a ton of `PartialEq` impls. There's no need for `PartialEq` in the trait definition of `FamStruct`, so let's just drop it and save us a bunch of pain. Co-authored-by: Patrick Roy <roypat@amazon.co.uk> Signed-off-by: Ruoqing He <heruoqing@iscas.ac.cn>
1 parent 8bb9b9e commit f010ccd

File tree

1 file changed

+5
-2
lines changed

1 file changed

+5
-2
lines changed

src/fam.rs

Lines changed: 5 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -126,7 +126,7 @@ impl fmt::Display for Error {
126126
#[allow(clippy::len_without_is_empty)]
127127
pub unsafe trait FamStruct {
128128
/// The type of the FAM entries
129-
type Entry: PartialEq + Copy;
129+
type Entry: Copy;
130130

131131
/// Get the FAM length
132132
///
@@ -505,7 +505,10 @@ impl<T: Default + FamStruct> FamStructWrapper<T> {
505505
}
506506
}
507507

508-
impl<T: Default + FamStruct + PartialEq> PartialEq for FamStructWrapper<T> {
508+
impl<T: Default + FamStruct + PartialEq> PartialEq for FamStructWrapper<T>
509+
where
510+
T::Entry: PartialEq,
511+
{
509512
fn eq(&self, other: &FamStructWrapper<T>) -> bool {
510513
self.as_fam_struct_ref() == other.as_fam_struct_ref() && self.as_slice() == other.as_slice()
511514
}

0 commit comments

Comments
 (0)