Skip to content

Commit

Permalink
MacOS: move ifconf to s_no_extra_traits
Browse files Browse the repository at this point in the history
The derived implementations were causing a CI failure that didn't show
up before. Manually implement `PartialEq` and `Debug` to work around
this.
  • Loading branch information
tgross35 authored and AkhilTThomas committed Feb 5, 2025
1 parent 7594935 commit 2f3c4aa
Showing 1 changed file with 27 additions and 0 deletions.
27 changes: 27 additions & 0 deletions src/unix/bsd/apple/mod.rs
Original file line number Diff line number Diff line change
Expand Up @@ -1694,6 +1694,32 @@ cfg_if! {

cfg_if! {
if #[cfg(feature = "extra_traits")] {
impl PartialEq for ifconf
where
Self: Copy
{
fn eq(&self, other: &Self) -> bool {
let len_ptr1 = core::ptr::addr_of!(self.ifc_len);
let len_ptr2 = core::ptr::addr_of!(other.ifc_len);
let ifcu_ptr1 = core::ptr::addr_of!(self.ifc_ifcu);
let ifcu_ptr2 = core::ptr::addr_of!(other.ifc_ifcu);

// SAFETY: `ifconf` implements `Copy` so the reads are valid
let len1 = unsafe { len_ptr1.read_unaligned() };
let len2 = unsafe { len_ptr2.read_unaligned() };
let ifcu1 = unsafe { ifcu_ptr1.read_unaligned() };
let ifcu2 = unsafe { ifcu_ptr2.read_unaligned() };

len1 == len2 && ifcu1 == ifcu2
}
}
impl Eq for ifconf {}
impl ::fmt::Debug for ifconf {
fn fmt(&self, f: &mut ::fmt::Formatter) -> ::fmt::Result {
f.debug_struct("ifconf").finish_non_exhaustive()
}
}

impl PartialEq for kevent {
fn eq(&self, other: &kevent) -> bool {
self.ident == other.ident
Expand All @@ -1704,6 +1730,7 @@ cfg_if! {
&& self.udata == other.udata
}
}

impl Eq for kevent {}
impl fmt::Debug for kevent {
fn fmt(&self, f: &mut fmt::Formatter) -> fmt::Result {
Expand Down

0 comments on commit 2f3c4aa

Please sign in to comment.