From 459fbe6871514f09cfe40923cb01513b25768d7d Mon Sep 17 00:00:00 2001 From: Juan Aguilar Santillana Date: Sat, 7 Dec 2024 02:38:23 +0100 Subject: [PATCH] fix: make Debug impl for unions opaque --- src/macros.rs | 7 ++ src/unix/aix/mod.rs | 17 ----- src/unix/aix/powerpc64.rs | 26 ------- src/unix/bsd/apple/mod.rs | 64 +--------------- src/unix/bsd/freebsdlike/freebsd/mod.rs | 55 -------------- .../bsd/freebsdlike/freebsd/x86_64/mod.rs | 7 -- src/unix/bsd/netbsdlike/netbsd/aarch64.rs | 13 ---- src/unix/bsd/netbsdlike/netbsd/mod.rs | 22 ------ src/unix/bsd/netbsdlike/netbsd/riscv64.rs | 1 - src/unix/bsd/netbsdlike/openbsd/mod.rs | 24 ------ src/unix/haiku/native.rs | 25 ------- src/unix/linux_like/android/b32/arm.rs | 7 -- src/unix/linux_like/android/b32/x86/mod.rs | 7 -- src/unix/linux_like/android/mod.rs | 19 ----- .../linux_like/linux/gnu/b32/riscv32/mod.rs | 1 - .../linux_like/linux/gnu/b64/riscv64/mod.rs | 1 - src/unix/linux_like/linux/gnu/mod.rs | 9 ++- src/unix/linux_like/linux/mod.rs | 73 +------------------ .../linux_like/linux/musl/b64/riscv64/mod.rs | 1 - src/unix/linux_like/mod.rs | 2 - src/unix/nto/x86_64.rs | 12 --- src/unix/solarish/mod.rs | 20 ----- src/unix/solarish/solaris.rs | 1 - src/unix/solarish/x86_64.rs | 10 --- src/vxworks/mod.rs | 19 ----- 25 files changed, 17 insertions(+), 426 deletions(-) diff --git a/src/macros.rs b/src/macros.rs index a39d527919e6..c9d96b7ab290 100644 --- a/src/macros.rs +++ b/src/macros.rs @@ -159,6 +159,13 @@ macro_rules! s_no_extra_traits { $(#[$attr])* pub union $i { $($field)* } } + + #[cfg(feature = "extra_traits")] + impl ::core::fmt::Debug for $i { + fn fmt(&self, f: &mut ::core::fmt::Formatter<'_>) -> ::core::fmt::Result { + f.debug_struct(::core::stringify!($i)).finish_non_exhaustive() + } + } ); (it: $(#[$attr:meta])* pub struct $i:ident { $($field:tt)* }) => ( diff --git a/src/unix/aix/mod.rs b/src/unix/aix/mod.rs index 10cec449c034..ca94debe8865 100644 --- a/src/unix/aix/mod.rs +++ b/src/unix/aix/mod.rs @@ -575,14 +575,6 @@ cfg_if! { } } impl Eq for __sigaction_sa_union {} - impl fmt::Debug for __sigaction_sa_union { - fn fmt(&self, f: &mut fmt::Formatter<'_>) -> fmt::Result { - f.debug_struct("__sigaction_sa_union") - .field("__su_handler", unsafe { &self.__su_handler }) - .field("__su_sigaction", unsafe { &self.__su_sigaction }) - .finish() - } - } impl hash::Hash for __sigaction_sa_union { fn hash(&self, state: &mut H) { unsafe { @@ -627,15 +619,6 @@ cfg_if! { } } impl Eq for __poll_ctl_ext_u {} - impl fmt::Debug for __poll_ctl_ext_u { - fn fmt(&self, f: &mut fmt::Formatter<'_>) -> fmt::Result { - f.debug_struct("__poll_ctl_ext_u") - .field("addr", unsafe { &self.addr }) - .field("data32", unsafe { &self.data32 }) - .field("data", unsafe { &self.data }) - .finish() - } - } impl hash::Hash for __poll_ctl_ext_u { fn hash(&self, state: &mut H) { unsafe { diff --git a/src/unix/aix/powerpc64.rs b/src/unix/aix/powerpc64.rs index e9f5b1e1cf3a..921774611e29 100644 --- a/src/unix/aix/powerpc64.rs +++ b/src/unix/aix/powerpc64.rs @@ -356,14 +356,6 @@ cfg_if! { } } impl Eq for _kernel_simple_lock {} - impl fmt::Debug for _kernel_simple_lock { - fn fmt(&self, f: &mut fmt::Formatter<'_>) -> fmt::Result { - f.debug_struct("_kernel_simple_lock") - .field("_slock", unsafe { &self._slock }) - .field("_slockp", unsafe { &self._slockp }) - .finish() - } - } impl hash::Hash for _kernel_simple_lock { fn hash(&self, state: &mut H) { unsafe { @@ -475,15 +467,6 @@ cfg_if! { } } impl Eq for __ld_info_file {} - impl fmt::Debug for __ld_info_file { - fn fmt(&self, f: &mut fmt::Formatter<'_>) -> fmt::Result { - f.debug_struct("__ld_info_file") - .field("_ldinfo_fd", unsafe { &self._ldinfo_fd }) - .field("_ldinfo_fp", unsafe { &self._ldinfo_fp }) - .field("_core_offset", unsafe { &self._core_offset }) - .finish() - } - } impl hash::Hash for __ld_info_file { fn hash(&self, state: &mut H) { unsafe { @@ -544,15 +527,6 @@ cfg_if! { } } impl Eq for __pollfd_ext_u {} - impl fmt::Debug for __pollfd_ext_u { - fn fmt(&self, f: &mut fmt::Formatter<'_>) -> fmt::Result { - f.debug_struct("__pollfd_ext_u") - .field("addr", unsafe { &self.addr }) - .field("data32", unsafe { &self.data32 }) - .field("data", unsafe { &self.data }) - .finish() - } - } impl hash::Hash for __pollfd_ext_u { fn hash(&self, state: &mut H) { unsafe { diff --git a/src/unix/bsd/apple/mod.rs b/src/unix/bsd/apple/mod.rs index eaf924c7f323..89993257b38d 100644 --- a/src/unix/bsd/apple/mod.rs +++ b/src/unix/bsd/apple/mod.rs @@ -1680,13 +1680,6 @@ cfg_if! { } } impl Eq for semun {} - impl fmt::Debug for semun { - fn fmt(&self, f: &mut fmt::Formatter) -> fmt::Result { - f.debug_struct("semun") - .field("val", unsafe { &self.val }) - .finish() - } - } impl hash::Hash for semun { fn hash(&self, state: &mut H) { unsafe { self.val.hash(state) }; @@ -3009,15 +3002,6 @@ cfg_if! { } impl Eq for __c_anonymous_ifk_data {} - - impl fmt::Debug for __c_anonymous_ifk_data { - fn fmt(&self, f: &mut fmt::Formatter) -> fmt::Result { - f.debug_struct("__c_anonymous_ifk_data") - .field("ifk_ptr", unsafe { &self.ifk_ptr }) - .field("ifk_value", unsafe { &self.ifk_value }) - .finish() - } - } impl hash::Hash for __c_anonymous_ifk_data { fn hash(&self, state: &mut H) { unsafe { @@ -3080,32 +3064,7 @@ cfg_if! { impl Eq for __c_anonymous_ifr_ifru {} - impl fmt::Debug for __c_anonymous_ifr_ifru { - fn fmt(&self, f: &mut fmt::Formatter) -> fmt::Result { - f.debug_struct("__c_anonymous_ifr_ifru") - .field("ifru_addr", unsafe { &self.ifru_addr }) - .field("ifru_dstaddr", unsafe { &self.ifru_dstaddr }) - .field("ifru_broadaddr", unsafe { &self.ifru_broadaddr }) - .field("ifru_flags", unsafe { &self.ifru_flags }) - .field("ifru_metrics", unsafe { &self.ifru_metrics }) - .field("ifru_mtu", unsafe { &self.ifru_mtu }) - .field("ifru_phys", unsafe { &self.ifru_phys }) - .field("ifru_media", unsafe { &self.ifru_media }) - .field("ifru_intval", unsafe { &self.ifru_intval }) - .field("ifru_data", unsafe { &self.ifru_data }) - .field("ifru_devmtu", unsafe { &self.ifru_devmtu }) - .field("ifru_kpi", unsafe { &self.ifru_kpi }) - .field("ifru_wake_flags", unsafe { &self.ifru_wake_flags }) - .field("ifru_route_refcnt", unsafe { &self.ifru_route_refcnt }) - .field("ifru_cap", unsafe { &self.ifru_cap }) - .field("ifru_functional_type", unsafe { - &self.ifru_functional_type - }) - .finish() - } - } - - impl hash::Hash for __c_anonymous_ifr_ifru { + impl hash::Hash for __c_anonymous_ifr_ifru { fn hash(&self, state: &mut H) { unsafe { self.ifru_addr.hash(state); @@ -3158,12 +3117,6 @@ cfg_if! { } } - impl fmt::Debug for __c_anonymous_ifc_ifcu { - fn fmt(&self, f: &mut fmt::Formatter) -> fmt::Result { - f.debug_struct("ifc_ifcu").finish_non_exhaustive() - } - } - impl PartialEq for __c_anonymous_ifr_ifru6 { fn eq(&self, other: &__c_anonymous_ifr_ifru6) -> bool { unsafe { @@ -3185,21 +3138,6 @@ cfg_if! { impl Eq for __c_anonymous_ifr_ifru6 {} - impl fmt::Debug for __c_anonymous_ifr_ifru6 { - fn fmt(&self, f: &mut fmt::Formatter) -> fmt::Result { - f.debug_struct("__c_anonymous_ifr_ifru6") - .field("ifru_addr", unsafe { &self.ifru_addr }) - .field("ifru_dstaddr", unsafe { &self.ifru_dstaddr }) - .field("ifru_flags", unsafe { &self.ifru_flags }) - .field("ifru_flags6", unsafe { &self.ifru_flags6 }) - .field("ifru_metrics", unsafe { &self.ifru_metrics }) - .field("ifru_intval", unsafe { &self.ifru_intval }) - .field("ifru_data", unsafe { &self.ifru_data }) - .field("ifru_scope_id", unsafe { &self.ifru_scope_id }) - .finish() - } - } - impl hash::Hash for __c_anonymous_ifr_ifru6 { fn hash(&self, state: &mut H) { unsafe { diff --git a/src/unix/bsd/freebsdlike/freebsd/mod.rs b/src/unix/bsd/freebsdlike/freebsd/mod.rs index 1c48b7175db1..621958b95c16 100644 --- a/src/unix/bsd/freebsdlike/freebsd/mod.rs +++ b/src/unix/bsd/freebsdlike/freebsd/mod.rs @@ -1365,8 +1365,6 @@ s_no_extra_traits! { pub aio_sigevent: sigevent, } - // Can't correctly impl Debug for unions - #[allow(missing_debug_implementations)] pub union __c_anonymous_sigev_un { pub _threadid: crate::__lwpid_t, pub _sigev_thread: __c_anonymous_sigev_thread, @@ -1883,13 +1881,6 @@ cfg_if! { } } impl Eq for __c_anonymous_elf32_auxv_union {} - impl fmt::Debug for __c_anonymous_elf32_auxv_union { - fn fmt(&self, f: &mut fmt::Formatter) -> fmt::Result { - f.debug_struct("a_val") - .field("a_val", unsafe { &self.a_val }) - .finish() - } - } impl PartialEq for Elf32_Auxinfo { fn eq(&self, other: &Elf32_Auxinfo) -> bool { self.a_type == other.a_type && self.a_un == other.a_un @@ -1927,27 +1918,6 @@ cfg_if! { } } impl Eq for __c_anonymous_ifr_ifru {} - impl fmt::Debug for __c_anonymous_ifr_ifru { - fn fmt(&self, f: &mut fmt::Formatter) -> fmt::Result { - f.debug_struct("ifr_ifru") - .field("ifru_addr", unsafe { &self.ifru_addr }) - .field("ifru_dstaddr", unsafe { &self.ifru_dstaddr }) - .field("ifru_broadaddr", unsafe { &self.ifru_broadaddr }) - .field("ifru_buffer", unsafe { &self.ifru_buffer }) - .field("ifru_flags", unsafe { &self.ifru_flags }) - .field("ifru_index", unsafe { &self.ifru_index }) - .field("ifru_jid", unsafe { &self.ifru_jid }) - .field("ifru_metric", unsafe { &self.ifru_metric }) - .field("ifru_mtu", unsafe { &self.ifru_mtu }) - .field("ifru_phys", unsafe { &self.ifru_phys }) - .field("ifru_media", unsafe { &self.ifru_media }) - .field("ifru_data", unsafe { &self.ifru_data }) - .field("ifru_cap", unsafe { &self.ifru_cap }) - .field("ifru_fib", unsafe { &self.ifru_fib }) - .field("ifru_vlan_pcp", unsafe { &self.ifru_vlan_pcp }) - .finish() - } - } impl hash::Hash for __c_anonymous_ifr_ifru { fn hash(&self, state: &mut H) { unsafe { self.ifru_addr.hash(state) }; @@ -1997,15 +1967,6 @@ cfg_if! { } } - impl fmt::Debug for __c_anonymous_ifc_ifcu { - fn fmt(&self, f: &mut fmt::Formatter) -> fmt::Result { - f.debug_struct("ifc_ifcu") - .field("ifcu_buf", unsafe { &self.ifcu_buf }) - .field("ifcu_req", unsafe { &self.ifcu_req }) - .finish() - } - } - impl hash::Hash for __c_anonymous_ifc_ifcu { fn hash(&self, state: &mut H) { unsafe { self.ifcu_buf.hash(state) }; @@ -2114,14 +2075,6 @@ cfg_if! { } } impl Eq for __c_anonymous_ifi_epoch {} - impl fmt::Debug for __c_anonymous_ifi_epoch { - fn fmt(&self, f: &mut fmt::Formatter) -> fmt::Result { - f.debug_struct("__c_anonymous_ifi_epoch") - .field("tt", unsafe { &self.tt }) - .field("ph", unsafe { &self.ph }) - .finish() - } - } impl hash::Hash for __c_anonymous_ifi_epoch { fn hash(&self, state: &mut H) { unsafe { @@ -2137,14 +2090,6 @@ cfg_if! { } } impl Eq for __c_anonymous_ifi_lastchange {} - impl fmt::Debug for __c_anonymous_ifi_lastchange { - fn fmt(&self, f: &mut fmt::Formatter) -> fmt::Result { - f.debug_struct("__c_anonymous_ifi_lastchange") - .field("tv", unsafe { &self.tv }) - .field("ph", unsafe { &self.ph }) - .finish() - } - } impl hash::Hash for __c_anonymous_ifi_lastchange { fn hash(&self, state: &mut H) { unsafe { diff --git a/src/unix/bsd/freebsdlike/freebsd/x86_64/mod.rs b/src/unix/bsd/freebsdlike/freebsd/x86_64/mod.rs index b3ed7684154a..435faa1d26a8 100644 --- a/src/unix/bsd/freebsdlike/freebsd/x86_64/mod.rs +++ b/src/unix/bsd/freebsdlike/freebsd/x86_64/mod.rs @@ -248,13 +248,6 @@ cfg_if! { } } impl Eq for __c_anonymous_elf64_auxv_union {} - impl fmt::Debug for __c_anonymous_elf64_auxv_union { - fn fmt(&self, f: &mut fmt::Formatter) -> fmt::Result { - f.debug_struct("a_val") - .field("a_val", unsafe { &self.a_val }) - .finish() - } - } impl PartialEq for Elf64_Auxinfo { fn eq(&self, other: &Elf64_Auxinfo) -> bool { self.a_type == other.a_type && self.a_un == other.a_un diff --git a/src/unix/bsd/netbsdlike/netbsd/aarch64.rs b/src/unix/bsd/netbsdlike/netbsd/aarch64.rs index 8ed84021e895..2391801fe458 100644 --- a/src/unix/bsd/netbsdlike/netbsd/aarch64.rs +++ b/src/unix/bsd/netbsdlike/netbsd/aarch64.rs @@ -54,19 +54,6 @@ cfg_if! { } } impl Eq for __c_anonymous__freg {} - impl fmt::Debug for __c_anonymous__freg { - fn fmt(&self, f: &mut fmt::Formatter) -> fmt::Result { - unsafe { - f.debug_struct("__c_anonymous__freg") - .field("__b8", &self.__b8) - .field("__h16", &self.__h16) - .field("__s32", &self.__s32) - .field("__d64", &self.__d64) - .field("__q128", &self.__q128) - .finish() - } - } - } impl hash::Hash for __c_anonymous__freg { fn hash(&self, state: &mut H) { unsafe { diff --git a/src/unix/bsd/netbsdlike/netbsd/mod.rs b/src/unix/bsd/netbsdlike/netbsd/mod.rs index 0d8ba6038baa..1840015e1d14 100644 --- a/src/unix/bsd/netbsdlike/netbsd/mod.rs +++ b/src/unix/bsd/netbsdlike/netbsd/mod.rs @@ -1340,17 +1340,6 @@ cfg_if! { } } - impl fmt::Debug for __c_anonymous_posix_spawn_fae { - fn fmt(&self, f: &mut fmt::Formatter) -> fmt::Result { - unsafe { - f.debug_struct("__c_anonymous_posix_fae") - .field("open", &self.open) - .field("dup2", &self.dup2) - .finish() - } - } - } - impl hash::Hash for __c_anonymous_posix_spawn_fae { fn hash(&self, state: &mut H) { unsafe { @@ -1368,17 +1357,6 @@ cfg_if! { } } - impl fmt::Debug for __c_anonymous_ifc_ifcu { - fn fmt(&self, f: &mut fmt::Formatter) -> fmt::Result { - unsafe { - f.debug_struct("__c_anonymous_ifc_ifcu") - .field("ifcu_buf", &self.ifcu_buf) - .field("ifcu_req", &self.ifcu_req) - .finish() - } - } - } - impl hash::Hash for __c_anonymous_ifc_ifcu { fn hash(&self, state: &mut H) { unsafe { diff --git a/src/unix/bsd/netbsdlike/netbsd/riscv64.rs b/src/unix/bsd/netbsdlike/netbsd/riscv64.rs index b5e72084d5aa..68cd264aadb7 100644 --- a/src/unix/bsd/netbsdlike/netbsd/riscv64.rs +++ b/src/unix/bsd/netbsdlike/netbsd/riscv64.rs @@ -19,7 +19,6 @@ s! { } s_no_extra_traits! { - #[cfg_attr(feature = "extra_traits", allow(missing_debug_implementations))] pub union __fpreg { pub u_u64: u64, pub u_d: c_double, diff --git a/src/unix/bsd/netbsdlike/openbsd/mod.rs b/src/unix/bsd/netbsdlike/openbsd/mod.rs index 3a94364965de..c15c2e77a149 100644 --- a/src/unix/bsd/netbsdlike/openbsd/mod.rs +++ b/src/unix/bsd/netbsdlike/openbsd/mod.rs @@ -943,14 +943,6 @@ cfg_if! { impl Eq for mount_info {} - impl fmt::Debug for mount_info { - fn fmt(&self, f: &mut fmt::Formatter) -> fmt::Result { - f.debug_struct("mount_info") - // FIXME: .field("align", &self.align) - .finish() - } - } - impl hash::Hash for mount_info { fn hash(&self, state: &mut H) { unsafe { self.align.hash(state) }; @@ -975,22 +967,6 @@ cfg_if! { impl Eq for __c_anonymous_ifr_ifru {} - impl fmt::Debug for __c_anonymous_ifr_ifru { - fn fmt(&self, f: &mut fmt::Formatter) -> fmt::Result { - f.debug_struct("__c_anonymous_ifr_ifru") - .field("ifru_addr", unsafe { &self.ifru_addr }) - .field("ifru_dstaddr", unsafe { &self.ifru_dstaddr }) - .field("ifru_broadaddr", unsafe { &self.ifru_broadaddr }) - .field("ifru_flags", unsafe { &self.ifru_flags }) - .field("ifru_metric", unsafe { &self.ifru_metric }) - .field("ifru_vnetid", unsafe { &self.ifru_vnetid }) - .field("ifru_media", unsafe { &self.ifru_media }) - .field("ifru_data", unsafe { &self.ifru_data }) - .field("ifru_index", unsafe { &self.ifru_index }) - .finish() - } - } - impl hash::Hash for __c_anonymous_ifr_ifru { fn hash(&self, state: &mut H) { unsafe { diff --git a/src/unix/haiku/native.rs b/src/unix/haiku/native.rs index 84ca0e146294..d373a9ced086 100644 --- a/src/unix/haiku/native.rs +++ b/src/unix/haiku/native.rs @@ -501,20 +501,6 @@ cfg_if! { } } impl Eq for cpuid_info {} - impl fmt::Debug for cpuid_info { - fn fmt(&self, f: &mut fmt::Formatter) -> fmt::Result { - unsafe { - f.debug_struct("cpuid_info") - .field("eax_0", &self.eax_0) - .field("eax_1", &self.eax_1) - .field("eax_2", &self.eax_2) - .field("eax_3", &self.eax_3) - .field("as_chars", &self.as_chars) - .field("regs", &self.regs) - .finish() - } - } - } impl PartialEq for __c_anonymous_cpu_topology_info_data { fn eq(&self, other: &__c_anonymous_cpu_topology_info_data) -> bool { @@ -526,17 +512,6 @@ cfg_if! { } } impl Eq for __c_anonymous_cpu_topology_info_data {} - impl fmt::Debug for __c_anonymous_cpu_topology_info_data { - fn fmt(&self, f: &mut fmt::Formatter) -> fmt::Result { - unsafe { - f.debug_struct("__c_anonymous_cpu_topology_info_data") - .field("root", &self.root) - .field("package", &self.package) - .field("core", &self.core) - .finish() - } - } - } impl PartialEq for cpu_topology_node_info { fn eq(&self, other: &cpu_topology_node_info) -> bool { diff --git a/src/unix/linux_like/android/b32/arm.rs b/src/unix/linux_like/android/b32/arm.rs index 8a3b02dcc402..0bf4087fde75 100644 --- a/src/unix/linux_like/android/b32/arm.rs +++ b/src/unix/linux_like/android/b32/arm.rs @@ -87,13 +87,6 @@ cfg_if! { } } impl Eq for __c_anonymous_uc_sigmask {} - impl fmt::Debug for __c_anonymous_uc_sigmask { - fn fmt(&self, f: &mut fmt::Formatter) -> fmt::Result { - f.debug_struct("uc_sigmask") - .field("uc_sigmask", unsafe { &self.uc_sigmask }) - .finish() - } - } impl hash::Hash for __c_anonymous_uc_sigmask { fn hash(&self, state: &mut H) { unsafe { self.uc_sigmask.hash(state) } diff --git a/src/unix/linux_like/android/b32/x86/mod.rs b/src/unix/linux_like/android/b32/x86/mod.rs index 8421f389ed9c..9f80d8a71f44 100644 --- a/src/unix/linux_like/android/b32/x86/mod.rs +++ b/src/unix/linux_like/android/b32/x86/mod.rs @@ -89,13 +89,6 @@ cfg_if! { } } impl Eq for __c_anonymous_uc_sigmask {} - impl fmt::Debug for __c_anonymous_uc_sigmask { - fn fmt(&self, f: &mut fmt::Formatter) -> fmt::Result { - f.debug_struct("uc_sigmask") - .field("uc_sigmask", unsafe { &self.uc_sigmask }) - .finish() - } - } impl hash::Hash for __c_anonymous_uc_sigmask { fn hash(&self, state: &mut H) { unsafe { self.uc_sigmask.hash(state) } diff --git a/src/unix/linux_like/android/mod.rs b/src/unix/linux_like/android/mod.rs index 524a6ad2c0f3..fd0048866e07 100644 --- a/src/unix/linux_like/android/mod.rs +++ b/src/unix/linux_like/android/mod.rs @@ -985,25 +985,6 @@ cfg_if! { } } - impl fmt::Debug for __c_anonymous_ifr_ifru { - fn fmt(&self, f: &mut fmt::Formatter) -> fmt::Result { - f.debug_struct("ifr_ifru") - .field("ifru_addr", unsafe { &self.ifru_addr }) - .field("ifru_dstaddr", unsafe { &self.ifru_dstaddr }) - .field("ifru_broadaddr", unsafe { &self.ifru_broadaddr }) - .field("ifru_netmask", unsafe { &self.ifru_netmask }) - .field("ifru_hwaddr", unsafe { &self.ifru_hwaddr }) - .field("ifru_flags", unsafe { &self.ifru_flags }) - .field("ifru_ifindex", unsafe { &self.ifru_ifindex }) - .field("ifru_metric", unsafe { &self.ifru_metric }) - .field("ifru_mtu", unsafe { &self.ifru_mtu }) - .field("ifru_map", unsafe { &self.ifru_map }) - .field("ifru_slave", unsafe { &self.ifru_slave }) - .field("ifru_newname", unsafe { &self.ifru_newname }) - .field("ifru_data", unsafe { &self.ifru_data }) - .finish() - } - } impl fmt::Debug for ifreq { fn fmt(&self, f: &mut fmt::Formatter) -> fmt::Result { f.debug_struct("ifreq") diff --git a/src/unix/linux_like/linux/gnu/b32/riscv32/mod.rs b/src/unix/linux_like/linux/gnu/b32/riscv32/mod.rs index 4ab40c628a1e..43547cc7ad86 100644 --- a/src/unix/linux_like/linux/gnu/b32/riscv32/mod.rs +++ b/src/unix/linux_like/linux/gnu/b32/riscv32/mod.rs @@ -212,7 +212,6 @@ s_no_extra_traits! { pub __fpregs: __riscv_mc_fp_state, } - #[allow(missing_debug_implementations)] pub union __riscv_mc_fp_state { pub __f: __riscv_mc_f_ext_state, pub __d: __riscv_mc_d_ext_state, diff --git a/src/unix/linux_like/linux/gnu/b64/riscv64/mod.rs b/src/unix/linux_like/linux/gnu/b64/riscv64/mod.rs index 6eaa3cda10fc..db8deafe896b 100644 --- a/src/unix/linux_like/linux/gnu/b64/riscv64/mod.rs +++ b/src/unix/linux_like/linux/gnu/b64/riscv64/mod.rs @@ -264,7 +264,6 @@ s_no_extra_traits! { pub __fpregs: __riscv_mc_fp_state, } - #[allow(missing_debug_implementations)] pub union __riscv_mc_fp_state { pub __f: __riscv_mc_f_ext_state, pub __d: __riscv_mc_d_ext_state, diff --git a/src/unix/linux_like/linux/gnu/mod.rs b/src/unix/linux_like/linux/gnu/mod.rs index e6272d3547b1..9e1002b1413d 100644 --- a/src/unix/linux_like/linux/gnu/mod.rs +++ b/src/unix/linux_like/linux/gnu/mod.rs @@ -557,7 +557,8 @@ s_no_extra_traits! { cfg_if! { if #[cfg(feature = "extra_traits")] { - impl PartialEq for utmpx { + use core::iter::Iterator; + impl core::cmp::PartialEq for utmpx { fn eq(&self, other: &utmpx) -> bool { self.ut_type == other.ut_type && self.ut_pid == other.ut_pid @@ -577,7 +578,7 @@ cfg_if! { } } - impl Eq for utmpx {} + impl core::cmp::Eq for utmpx {} impl fmt::Debug for utmpx { fn fmt(&self, f: &mut fmt::Formatter) -> fmt::Result { @@ -613,7 +614,7 @@ cfg_if! { } } - impl PartialEq for __c_anonymous_ptrace_syscall_info_data { + impl core::cmp::PartialEq for __c_anonymous_ptrace_syscall_info_data { fn eq(&self, other: &__c_anonymous_ptrace_syscall_info_data) -> bool { unsafe { self.entry == other.entry @@ -623,7 +624,7 @@ cfg_if! { } } - impl Eq for __c_anonymous_ptrace_syscall_info_data {} + impl core::cmp::Eq for __c_anonymous_ptrace_syscall_info_data {} impl fmt::Debug for __c_anonymous_ptrace_syscall_info_data { fn fmt(&self, f: &mut fmt::Formatter) -> fmt::Result { diff --git a/src/unix/linux_like/linux/mod.rs b/src/unix/linux_like/linux/mod.rs index 0a958b4f6b4c..60f2419ab587 100644 --- a/src/unix/linux_like/linux/mod.rs +++ b/src/unix/linux_like/linux/mod.rs @@ -1740,19 +1740,16 @@ s_no_extra_traits! { } // linux/ptp_clock.h - #[allow(missing_debug_implementations)] pub union __c_anonymous_ptp_perout_request_1 { pub start: ptp_clock_time, pub phase: ptp_clock_time, } - #[allow(missing_debug_implementations)] pub union __c_anonymous_ptp_perout_request_2 { pub on: ptp_clock_time, pub rsv: [c_uint; 4], } - #[allow(missing_debug_implementations)] pub struct ptp_perout_request { pub anonymous_1: __c_anonymous_ptp_perout_request_1, pub period: ptp_clock_time, @@ -1762,13 +1759,11 @@ s_no_extra_traits! { } // linux/if_xdp.h - #[allow(missing_debug_implementations)] pub struct xsk_tx_metadata { pub flags: crate::__u64, pub xsk_tx_metadata_union: __c_anonymous_xsk_tx_metadata_union, } - #[allow(missing_debug_implementations)] pub union __c_anonymous_xsk_tx_metadata_union { pub request: xsk_tx_metadata_request, pub completion: xsk_tx_metadata_completion, @@ -2101,26 +2096,7 @@ cfg_if! { self.mq_curmsgs.hash(state); } } - impl fmt::Debug for __c_anonymous_ifr_ifru { - fn fmt(&self, f: &mut fmt::Formatter) -> fmt::Result { - f.debug_struct("ifr_ifru") - .field("ifru_addr", unsafe { &self.ifru_addr }) - .field("ifru_dstaddr", unsafe { &self.ifru_dstaddr }) - .field("ifru_broadaddr", unsafe { &self.ifru_broadaddr }) - .field("ifru_netmask", unsafe { &self.ifru_netmask }) - .field("ifru_hwaddr", unsafe { &self.ifru_hwaddr }) - .field("ifru_flags", unsafe { &self.ifru_flags }) - .field("ifru_ifindex", unsafe { &self.ifru_ifindex }) - .field("ifru_metric", unsafe { &self.ifru_metric }) - .field("ifru_mtu", unsafe { &self.ifru_mtu }) - .field("ifru_map", unsafe { &self.ifru_map }) - .field("ifru_slave", unsafe { &self.ifru_slave }) - .field("ifru_newname", unsafe { &self.ifru_newname }) - .field("ifru_data", unsafe { &self.ifru_data }) - .finish() - } - } - impl fmt::Debug for ifreq { + impl fmt::Debug for ifreq { fn fmt(&self, f: &mut fmt::Formatter) -> fmt::Result { f.debug_struct("ifreq") .field("ifr_name", &self.ifr_name) @@ -2128,15 +2104,6 @@ cfg_if! { .finish() } } - - impl fmt::Debug for __c_anonymous_ifc_ifcu { - fn fmt(&self, f: &mut fmt::Formatter) -> fmt::Result { - f.debug_struct("ifr_ifru") - .field("ifcu_buf", unsafe { &self.ifcu_buf }) - .field("ifcu_req", unsafe { &self.ifcu_req }) - .finish() - } - } impl fmt::Debug for ifconf { fn fmt(&self, f: &mut fmt::Formatter) -> fmt::Result { f.debug_struct("ifconf") @@ -2210,32 +2177,7 @@ cfg_if! { } } - impl fmt::Debug for iwreq_data { - fn fmt(&self, f: &mut fmt::Formatter) -> fmt::Result { - f.debug_struct("iwreq_data") - .field("name", unsafe { &self.name }) - .field("essid", unsafe { &self.essid }) - .field("nwid", unsafe { &self.nwid }) - .field("freq", unsafe { &self.freq }) - .field("sens", unsafe { &self.sens }) - .field("bitrate", unsafe { &self.bitrate }) - .field("txpower", unsafe { &self.txpower }) - .field("rts", unsafe { &self.rts }) - .field("frag", unsafe { &self.frag }) - .field("mode", unsafe { &self.mode }) - .field("retry", unsafe { &self.retry }) - .field("encoding", unsafe { &self.encoding }) - .field("power", unsafe { &self.power }) - .field("qual", unsafe { &self.qual }) - .field("ap_addr", unsafe { &self.ap_addr }) - .field("addr", unsafe { &self.addr }) - .field("param", unsafe { &self.param }) - .field("data", unsafe { &self.data }) - .finish() - } - } - - impl fmt::Debug for iw_event { + impl fmt::Debug for iw_event { fn fmt(&self, f: &mut fmt::Formatter) -> fmt::Result { f.debug_struct("iw_event") .field("len", &self.len) @@ -2245,14 +2187,6 @@ cfg_if! { } } - impl fmt::Debug for __c_anonymous_iwreq { - fn fmt(&self, f: &mut fmt::Formatter) -> fmt::Result { - f.debug_struct("__c_anonymous_iwreq") - .field("ifrn_name", unsafe { &self.ifrn_name }) - .finish() - } - } - impl fmt::Debug for iwreq { fn fmt(&self, f: &mut fmt::Formatter) -> fmt::Result { f.debug_struct("iwreq") @@ -5744,7 +5678,8 @@ pub const XDP_UMEM_PGOFF_FILL_RING: crate::c_ulonglong = 0x100000000; pub const XDP_UMEM_PGOFF_COMPLETION_RING: crate::c_ulonglong = 0x180000000; pub const XSK_UNALIGNED_BUF_OFFSET_SHIFT: crate::c_int = 48; -pub const XSK_UNALIGNED_BUF_ADDR_MASK: crate::c_ulonglong = (1 << XSK_UNALIGNED_BUF_OFFSET_SHIFT) - 1; +pub const XSK_UNALIGNED_BUF_ADDR_MASK: crate::c_ulonglong = + (1 << XSK_UNALIGNED_BUF_OFFSET_SHIFT) - 1; pub const XDP_PKT_CONTD: crate::__u32 = 1 << 0; diff --git a/src/unix/linux_like/linux/musl/b64/riscv64/mod.rs b/src/unix/linux_like/linux/musl/b64/riscv64/mod.rs index 729e87366887..ec0ba4c1f926 100644 --- a/src/unix/linux_like/linux/musl/b64/riscv64/mod.rs +++ b/src/unix/linux_like/linux/musl/b64/riscv64/mod.rs @@ -103,7 +103,6 @@ s_no_extra_traits! { pub __fpregs: __riscv_mc_fp_state, } - #[allow(missing_debug_implementations)] pub union __riscv_mc_fp_state { pub __f: __riscv_mc_f_ext_state, pub __d: __riscv_mc_d_ext_state, diff --git a/src/unix/linux_like/mod.rs b/src/unix/linux_like/mod.rs index 8f6f3db5aed0..b856ed5cd358 100644 --- a/src/unix/linux_like/mod.rs +++ b/src/unix/linux_like/mod.rs @@ -268,8 +268,6 @@ s_no_extra_traits! { pub u64: u64, } - // Can't correctly impl Debug for unions - #[allow(missing_debug_implementations)] pub union __c_anonymous_sigev_un { _pad: [c_int; SIGEV_PAD_SIZE], pub _tid: c_int, diff --git a/src/unix/nto/x86_64.rs b/src/unix/nto/x86_64.rs index 8e938c3bba4f..425f47994946 100644 --- a/src/unix/nto/x86_64.rs +++ b/src/unix/nto/x86_64.rs @@ -101,18 +101,6 @@ cfg_if! { } } - impl fmt::Debug for x86_64_fpu_registers { - fn fmt(&self, f: &mut fmt::Formatter) -> fmt::Result { - unsafe { - f.debug_struct("x86_64_fpu_registers") - .field("fsave_area", &self.fsave_area) - .field("fxsave_area", &self.fxsave_area) - .field("xsave_area", &self.xsave_area) - .finish() - } - } - } - impl hash::Hash for x86_64_fpu_registers { fn hash(&self, state: &mut H) { unsafe { diff --git a/src/unix/solarish/mod.rs b/src/unix/solarish/mod.rs index 70e549a1b5d8..9fce13226afc 100644 --- a/src/unix/solarish/mod.rs +++ b/src/unix/solarish/mod.rs @@ -859,16 +859,6 @@ cfg_if! { } } impl Eq for pad128_t {} - impl fmt::Debug for pad128_t { - fn fmt(&self, f: &mut fmt::Formatter) -> fmt::Result { - unsafe { - f.debug_struct("pad128_t") - // FIXME: .field("_q", &{self._q}) - .field("_l", &{ self._l }) - .finish() - } - } - } impl hash::Hash for pad128_t { fn hash(&self, state: &mut H) { unsafe { @@ -886,16 +876,6 @@ cfg_if! { } } impl Eq for upad128_t {} - impl fmt::Debug for upad128_t { - fn fmt(&self, f: &mut fmt::Formatter) -> fmt::Result { - unsafe { - f.debug_struct("upad128_t") - // FIXME: .field("_q", &{self._q}) - .field("_l", &{ self._l }) - .finish() - } - } - } impl hash::Hash for upad128_t { fn hash(&self, state: &mut H) { unsafe { diff --git a/src/unix/solarish/solaris.rs b/src/unix/solarish/solaris.rs index 44fbc6fcdc49..e1cddc385f28 100644 --- a/src/unix/solarish/solaris.rs +++ b/src/unix/solarish/solaris.rs @@ -65,7 +65,6 @@ s_no_extra_traits! { pub d_id: crate::door_id_t, } - #[cfg_attr(feature = "extra_traits", allow(missing_debug_implementations))] pub union door_desc_t__d_data { pub d_desc: door_desc_t__d_data__d_desc, d_resv: [c_int; 5], /* Check out /usr/include/sys/door.h */ diff --git a/src/unix/solarish/x86_64.rs b/src/unix/solarish/x86_64.rs index 1ea8ce987dab..4deaac0fc171 100644 --- a/src/unix/solarish/x86_64.rs +++ b/src/unix/solarish/x86_64.rs @@ -110,16 +110,6 @@ cfg_if! { } } impl Eq for __c_anonymous_fp_reg_set {} - impl fmt::Debug for __c_anonymous_fp_reg_set { - fn fmt(&self, f: &mut fmt::Formatter) -> fmt::Result { - unsafe { - f.debug_struct("__c_anonymous_fp_reg_set") - .field("fpchip_state", &{ self.fpchip_state }) - .field("f_fpregs", &{ self.f_fpregs }) - .finish() - } - } - } impl PartialEq for fpregset_t { fn eq(&self, other: &fpregset_t) -> bool { self.fp_reg_set == other.fp_reg_set diff --git a/src/vxworks/mod.rs b/src/vxworks/mod.rs index d90957642c0d..876881717147 100644 --- a/src/vxworks/mod.rs +++ b/src/vxworks/mod.rs @@ -533,18 +533,6 @@ cfg_if! { } } impl Eq for sa_u_t {} - impl fmt::Debug for sa_u_t { - fn fmt(&self, f: &mut fmt::Formatter) -> fmt::Result { - unsafe { - let h = match self.sa_handler { - Some(handler) => handler as usize, - None => 0 as usize, - }; - - f.debug_struct("sa_u_t").field("sa_handler", &h).finish() - } - } - } impl hash::Hash for sa_u_t { fn hash(&self, state: &mut H) { unsafe { @@ -563,13 +551,6 @@ cfg_if! { } } impl Eq for sigval {} - impl fmt::Debug for sigval { - fn fmt(&self, f: &mut fmt::Formatter) -> fmt::Result { - f.debug_struct("sigval") - .field("sival_ptr", unsafe { &(self.sival_ptr as usize) }) - .finish() - } - } impl hash::Hash for sigval { fn hash(&self, state: &mut H) { unsafe { (self.sival_ptr as usize).hash(state) };