Skip to content

Commit 06de0f6

Browse files
committed
fix: fix: make Debug impl for unions opaque
1 parent 149d392 commit 06de0f6

File tree

2 files changed

+11
-64
lines changed

2 files changed

+11
-64
lines changed

src/macros.rs

Lines changed: 7 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -159,6 +159,13 @@ macro_rules! s_no_extra_traits {
159159
$(#[$attr])*
160160
pub union $i { $($field)* }
161161
}
162+
163+
#[cfg(feature = "extra_traits")]
164+
impl ::core::fmt::Debug for $i {
165+
fn fmt(&self, f: &mut ::core::fmt::Formatter<'_>) -> ::core::fmt::Result {
166+
f.debug_struct(::core::stringify!($i)).finish_non_exhaustive()
167+
}
168+
}
162169
);
163170

164171
(it: $(#[$attr:meta])* pub struct $i:ident { $($field:tt)* }) => (

src/unix/linux_like/linux/mod.rs

Lines changed: 4 additions & 64 deletions
Original file line numberDiff line numberDiff line change
@@ -2101,42 +2101,14 @@ cfg_if! {
21012101
self.mq_curmsgs.hash(state);
21022102
}
21032103
}
2104-
impl fmt::Debug for __c_anonymous_ifr_ifru {
2105-
fn fmt(&self, f: &mut fmt::Formatter) -> fmt::Result {
2106-
f.debug_struct("ifr_ifru")
2107-
.field("ifru_addr", unsafe { &self.ifru_addr })
2108-
.field("ifru_dstaddr", unsafe { &self.ifru_dstaddr })
2109-
.field("ifru_broadaddr", unsafe { &self.ifru_broadaddr })
2110-
.field("ifru_netmask", unsafe { &self.ifru_netmask })
2111-
.field("ifru_hwaddr", unsafe { &self.ifru_hwaddr })
2112-
.field("ifru_flags", unsafe { &self.ifru_flags })
2113-
.field("ifru_ifindex", unsafe { &self.ifru_ifindex })
2114-
.field("ifru_metric", unsafe { &self.ifru_metric })
2115-
.field("ifru_mtu", unsafe { &self.ifru_mtu })
2116-
.field("ifru_map", unsafe { &self.ifru_map })
2117-
.field("ifru_slave", unsafe { &self.ifru_slave })
2118-
.field("ifru_newname", unsafe { &self.ifru_newname })
2119-
.field("ifru_data", unsafe { &self.ifru_data })
2120-
.finish()
2121-
}
2122-
}
2123-
impl fmt::Debug for ifreq {
2104+
impl fmt::Debug for ifreq {
21242105
fn fmt(&self, f: &mut fmt::Formatter) -> fmt::Result {
21252106
f.debug_struct("ifreq")
21262107
.field("ifr_name", &self.ifr_name)
21272108
.field("ifr_ifru", &self.ifr_ifru)
21282109
.finish()
21292110
}
21302111
}
2131-
2132-
impl fmt::Debug for __c_anonymous_ifc_ifcu {
2133-
fn fmt(&self, f: &mut fmt::Formatter) -> fmt::Result {
2134-
f.debug_struct("ifr_ifru")
2135-
.field("ifcu_buf", unsafe { &self.ifcu_buf })
2136-
.field("ifcu_req", unsafe { &self.ifcu_req })
2137-
.finish()
2138-
}
2139-
}
21402112
impl fmt::Debug for ifconf {
21412113
fn fmt(&self, f: &mut fmt::Formatter) -> fmt::Result {
21422114
f.debug_struct("ifconf")
@@ -2210,32 +2182,7 @@ cfg_if! {
22102182
}
22112183
}
22122184

2213-
impl fmt::Debug for iwreq_data {
2214-
fn fmt(&self, f: &mut fmt::Formatter) -> fmt::Result {
2215-
f.debug_struct("iwreq_data")
2216-
.field("name", unsafe { &self.name })
2217-
.field("essid", unsafe { &self.essid })
2218-
.field("nwid", unsafe { &self.nwid })
2219-
.field("freq", unsafe { &self.freq })
2220-
.field("sens", unsafe { &self.sens })
2221-
.field("bitrate", unsafe { &self.bitrate })
2222-
.field("txpower", unsafe { &self.txpower })
2223-
.field("rts", unsafe { &self.rts })
2224-
.field("frag", unsafe { &self.frag })
2225-
.field("mode", unsafe { &self.mode })
2226-
.field("retry", unsafe { &self.retry })
2227-
.field("encoding", unsafe { &self.encoding })
2228-
.field("power", unsafe { &self.power })
2229-
.field("qual", unsafe { &self.qual })
2230-
.field("ap_addr", unsafe { &self.ap_addr })
2231-
.field("addr", unsafe { &self.addr })
2232-
.field("param", unsafe { &self.param })
2233-
.field("data", unsafe { &self.data })
2234-
.finish()
2235-
}
2236-
}
2237-
2238-
impl fmt::Debug for iw_event {
2185+
impl fmt::Debug for iw_event {
22392186
fn fmt(&self, f: &mut fmt::Formatter) -> fmt::Result {
22402187
f.debug_struct("iw_event")
22412188
.field("len", &self.len)
@@ -2245,14 +2192,6 @@ cfg_if! {
22452192
}
22462193
}
22472194

2248-
impl fmt::Debug for __c_anonymous_iwreq {
2249-
fn fmt(&self, f: &mut fmt::Formatter) -> fmt::Result {
2250-
f.debug_struct("__c_anonymous_iwreq")
2251-
.field("ifrn_name", unsafe { &self.ifrn_name })
2252-
.finish()
2253-
}
2254-
}
2255-
22562195
impl fmt::Debug for iwreq {
22572196
fn fmt(&self, f: &mut fmt::Formatter) -> fmt::Result {
22582197
f.debug_struct("iwreq")
@@ -5744,7 +5683,8 @@ pub const XDP_UMEM_PGOFF_FILL_RING: crate::c_ulonglong = 0x100000000;
57445683
pub const XDP_UMEM_PGOFF_COMPLETION_RING: crate::c_ulonglong = 0x180000000;
57455684

57465685
pub const XSK_UNALIGNED_BUF_OFFSET_SHIFT: crate::c_int = 48;
5747-
pub const XSK_UNALIGNED_BUF_ADDR_MASK: crate::c_ulonglong = (1 << XSK_UNALIGNED_BUF_OFFSET_SHIFT) - 1;
5686+
pub const XSK_UNALIGNED_BUF_ADDR_MASK: crate::c_ulonglong =
5687+
(1 << XSK_UNALIGNED_BUF_OFFSET_SHIFT) - 1;
57485688

57495689
pub const XDP_PKT_CONTD: crate::__u32 = 1 << 0;
57505690

0 commit comments

Comments
 (0)