Skip to content

Commit bca8be6

Browse files
committed
Layout related tests for derive Eq
1 parent b87f4ba commit bca8be6

14 files changed

+72
-70
lines changed

tests/expectations/tests/issue-648-derive-debug-with-padding.rs

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -30,8 +30,8 @@ impl Clone for NoDebug {
3030
impl Default for NoDebug {
3131
fn default() -> Self { unsafe { ::std::mem::zeroed() } }
3232
}
33-
/// This should derive Debug/Hash/PartialEq because the padding size is less than the max derive
34-
/// Debug/Hash/PartialEq impl for arrays. However, we conservatively don't derive Debug/Hash because
33+
/// This should derive Debug/Hash/PartialEq/Eq because the padding size is less than the max derive
34+
/// Debug/Hash/PartialEq/Eq impl for arrays. However, we conservatively don't derive Debug/Hash because
3535
/// we determine Debug derive-ability before we compute padding, which happens at
3636
/// codegen. (Again, we expect to get the alignment wrong for similar reasons.)
3737
#[repr(C)]

tests/expectations/tests/layout_array.rs

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -106,7 +106,7 @@ impl Default for rte_mempool_ops {
106106
}
107107
/// The rte_spinlock_t type.
108108
#[repr(C)]
109-
#[derive(Debug, Default, Copy, Hash, PartialEq)]
109+
#[derive(Debug, Default, Copy, Hash, PartialEq, Eq)]
110110
pub struct rte_spinlock_t {
111111
/// < lock status 0 = unlocked, 1 = locked
112112
pub locked: ::std::os::raw::c_int,
@@ -181,7 +181,7 @@ pub struct malloc_heap {
181181
pub total_size: usize,
182182
}
183183
#[repr(C)]
184-
#[derive(Debug, Copy, Hash, PartialEq)]
184+
#[derive(Debug, Copy, Hash, PartialEq, Eq)]
185185
pub struct malloc_heap__bindgen_ty_1 {
186186
pub lh_first: *mut malloc_elem,
187187
}
@@ -239,7 +239,7 @@ impl Default for malloc_heap {
239239
fn default() -> Self { unsafe { ::std::mem::zeroed() } }
240240
}
241241
#[repr(C)]
242-
#[derive(Debug, Default, Copy, Hash, PartialEq)]
242+
#[derive(Debug, Default, Copy, Hash, PartialEq, Eq)]
243243
pub struct malloc_elem {
244244
pub _address: u8,
245245
}

tests/expectations/tests/layout_array_too_long.rs

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -20,7 +20,7 @@ pub enum _bindgen_ty_1 {
2020
}
2121
/// @internal fragmented mbuf
2222
#[repr(C)]
23-
#[derive(Debug, Copy, Hash, PartialEq)]
23+
#[derive(Debug, Copy, Hash, PartialEq, Eq)]
2424
pub struct ip_frag {
2525
/// < offset into the packet
2626
pub ofs: u16,
@@ -59,7 +59,7 @@ impl Default for ip_frag {
5959
}
6060
/// @internal <src addr, dst_addr, id> to uniquely indetify fragmented datagram.
6161
#[repr(C)]
62-
#[derive(Debug, Default, Copy, Hash, PartialEq)]
62+
#[derive(Debug, Default, Copy, Hash, PartialEq, Eq)]
6363
pub struct ip_frag_key {
6464
/// < src address, first 8 bytes used for IPv4
6565
pub src_dst: [u64; 4usize],
@@ -115,7 +115,7 @@ pub struct ip_frag_pkt {
115115
pub __bindgen_padding_0: [u64; 6usize],
116116
}
117117
#[repr(C)]
118-
#[derive(Debug, Copy, Hash, PartialEq)]
118+
#[derive(Debug, Copy, Hash, PartialEq, Eq)]
119119
pub struct ip_frag_pkt__bindgen_ty_1 {
120120
pub tqe_next: *mut ip_frag_pkt,
121121
pub tqe_prev: *mut *mut ip_frag_pkt,
@@ -196,7 +196,7 @@ impl Default for ip_frag_pkt {
196196
}
197197
/// < fragment mbuf
198198
#[repr(C)]
199-
#[derive(Debug, Default, Copy, Hash, PartialEq)]
199+
#[derive(Debug, Default, Copy, Hash, PartialEq, Eq)]
200200
pub struct rte_mbuf {
201201
pub _address: u8,
202202
}

tests/expectations/tests/layout_eth_conf.rs

Lines changed: 17 additions & 17 deletions
Original file line numberDiff line numberDiff line change
@@ -52,7 +52,7 @@ pub enum rte_eth_rx_mq_mode {
5252
}
5353
/// A structure used to configure the RX features of an Ethernet port.
5454
#[repr(C)]
55-
#[derive(Debug, Copy, Hash, PartialEq)]
55+
#[derive(Debug, Copy, Hash, PartialEq, Eq)]
5656
pub struct rte_eth_rxmode {
5757
/// The multi-queue packet distribution mode to be used, e.g. RSS.
5858
pub mq_mode: rte_eth_rx_mq_mode,
@@ -470,7 +470,7 @@ pub enum rte_eth_tx_mq_mode {
470470
}
471471
/// A structure used to configure the TX features of an Ethernet port.
472472
#[repr(C)]
473-
#[derive(Debug, Copy, Hash, PartialEq)]
473+
#[derive(Debug, Copy, Hash, PartialEq, Eq)]
474474
pub struct rte_eth_txmode {
475475
/// < TX multi-queues mode.
476476
pub mq_mode: rte_eth_tx_mq_mode,
@@ -641,7 +641,7 @@ impl rte_eth_txmode {
641641
/// types of IPv4/IPv6 packets to which the RSS hashing must be applied.
642642
/// Supplying an *rss_hf* equal to zero disables the RSS feature.
643643
#[repr(C)]
644-
#[derive(Debug, Copy, Hash, PartialEq)]
644+
#[derive(Debug, Copy, Hash, PartialEq, Eq)]
645645
pub struct rte_eth_rss_conf {
646646
/// < If not NULL, 40-byte hash key.
647647
pub rss_key: *mut u8,
@@ -718,7 +718,7 @@ pub struct rte_eth_vmdq_dcb_conf {
718718
pub dcb_tc: [u8; 8usize],
719719
}
720720
#[repr(C)]
721-
#[derive(Debug, Default, Copy, Hash, PartialEq)]
721+
#[derive(Debug, Default, Copy, Hash, PartialEq, Eq)]
722722
pub struct rte_eth_vmdq_dcb_conf__bindgen_ty_1 {
723723
/// < The vlan id of the received frame
724724
pub vlan_id: u16,
@@ -798,7 +798,7 @@ impl Default for rte_eth_vmdq_dcb_conf {
798798
fn default() -> Self { unsafe { ::std::mem::zeroed() } }
799799
}
800800
#[repr(C)]
801-
#[derive(Debug, Copy, Hash, PartialEq)]
801+
#[derive(Debug, Copy, Hash, PartialEq, Eq)]
802802
pub struct rte_eth_dcb_rx_conf {
803803
/// < Possible DCB TCs, 4 or 8 TCs
804804
pub nb_tcs: rte_eth_nb_tcs,
@@ -830,7 +830,7 @@ impl Default for rte_eth_dcb_rx_conf {
830830
fn default() -> Self { unsafe { ::std::mem::zeroed() } }
831831
}
832832
#[repr(C)]
833-
#[derive(Debug, Copy, Hash, PartialEq)]
833+
#[derive(Debug, Copy, Hash, PartialEq, Eq)]
834834
pub struct rte_eth_vmdq_dcb_tx_conf {
835835
/// < With DCB, 16 or 32 pools.
836836
pub nb_queue_pools: rte_eth_nb_pools,
@@ -864,7 +864,7 @@ impl Default for rte_eth_vmdq_dcb_tx_conf {
864864
fn default() -> Self { unsafe { ::std::mem::zeroed() } }
865865
}
866866
#[repr(C)]
867-
#[derive(Debug, Copy, Hash, PartialEq)]
867+
#[derive(Debug, Copy, Hash, PartialEq, Eq)]
868868
pub struct rte_eth_dcb_tx_conf {
869869
/// < Possible DCB TCs, 4 or 8 TCs.
870870
pub nb_tcs: rte_eth_nb_tcs,
@@ -896,7 +896,7 @@ impl Default for rte_eth_dcb_tx_conf {
896896
fn default() -> Self { unsafe { ::std::mem::zeroed() } }
897897
}
898898
#[repr(C)]
899-
#[derive(Debug, Copy, Hash, PartialEq)]
899+
#[derive(Debug, Copy, Hash, PartialEq, Eq)]
900900
pub struct rte_eth_vmdq_tx_conf {
901901
/// < VMDq mode, 64 pools.
902902
pub nb_queue_pools: rte_eth_nb_pools,
@@ -939,7 +939,7 @@ pub struct rte_eth_vmdq_rx_conf {
939939
pub pool_map: [rte_eth_vmdq_rx_conf__bindgen_ty_1; 64usize],
940940
}
941941
#[repr(C)]
942-
#[derive(Debug, Default, Copy, Hash, PartialEq)]
942+
#[derive(Debug, Default, Copy, Hash, PartialEq, Eq)]
943943
pub struct rte_eth_vmdq_rx_conf__bindgen_ty_1 {
944944
/// < The vlan id of the received frame
945945
pub vlan_id: u16,
@@ -1052,7 +1052,7 @@ pub enum rte_fdir_status_mode {
10521052
}
10531053
/// A structure used to define the input for IPV4 flow
10541054
#[repr(C)]
1055-
#[derive(Debug, Default, Copy, Hash, PartialEq)]
1055+
#[derive(Debug, Default, Copy, Hash, PartialEq, Eq)]
10561056
pub struct rte_eth_ipv4_flow {
10571057
/// < IPv4 source address in big endian.
10581058
pub src_ip: u32,
@@ -1102,7 +1102,7 @@ impl Clone for rte_eth_ipv4_flow {
11021102
}
11031103
/// A structure used to define the input for IPV6 flow
11041104
#[repr(C)]
1105-
#[derive(Debug, Default, Copy, Hash, PartialEq)]
1105+
#[derive(Debug, Default, Copy, Hash, PartialEq, Eq)]
11061106
pub struct rte_eth_ipv6_flow {
11071107
/// < IPv6 source address in big endian.
11081108
pub src_ip: [u32; 4usize],
@@ -1153,7 +1153,7 @@ impl Clone for rte_eth_ipv6_flow {
11531153
/// A structure used to configure FDIR masks that are used by the device
11541154
/// to match the various fields of RX packet headers.
11551155
#[repr(C)]
1156-
#[derive(Debug, Default, Copy, Hash, PartialEq)]
1156+
#[derive(Debug, Default, Copy, Hash, PartialEq, Eq)]
11571157
pub struct rte_eth_fdir_masks {
11581158
/// < Bit mask for vlan_tci in big endian
11591159
pub vlan_tci_mask: u16,
@@ -1239,7 +1239,7 @@ pub enum rte_eth_payload_type {
12391239
/// A structure used to select bytes extracted from the protocol layers to
12401240
/// flexible payload for filter
12411241
#[repr(C)]
1242-
#[derive(Debug, Copy, Hash, PartialEq)]
1242+
#[derive(Debug, Copy, Hash, PartialEq, Eq)]
12431243
pub struct rte_eth_flex_payload_cfg {
12441244
/// < Payload type
12451245
pub type_: rte_eth_payload_type,
@@ -1274,7 +1274,7 @@ impl Default for rte_eth_flex_payload_cfg {
12741274
/// A structure used to define FDIR masks for flexible payload
12751275
/// for each flow type
12761276
#[repr(C)]
1277-
#[derive(Debug, Default, Copy, Hash, PartialEq)]
1277+
#[derive(Debug, Default, Copy, Hash, PartialEq, Eq)]
12781278
pub struct rte_eth_fdir_flex_mask {
12791279
pub flow_type: u16,
12801280
pub mask: [u8; 16usize],
@@ -1304,7 +1304,7 @@ impl Clone for rte_eth_fdir_flex_mask {
13041304
/// A structure used to define all flexible payload related setting
13051305
/// include flex payload and flex mask
13061306
#[repr(C)]
1307-
#[derive(Debug, Copy, Hash, PartialEq)]
1307+
#[derive(Debug, Copy, Hash, PartialEq, Eq)]
13081308
pub struct rte_eth_fdir_flex_conf {
13091309
/// < The number of following payload cfg
13101310
pub nb_payloads: u16,
@@ -1353,7 +1353,7 @@ impl Default for rte_eth_fdir_flex_conf {
13531353
///
13541354
/// If mode is RTE_FDIR_DISABLE, the pballoc value is ignored.
13551355
#[repr(C)]
1356-
#[derive(Debug, Copy, Hash, PartialEq)]
1356+
#[derive(Debug, Copy, Hash, PartialEq, Eq)]
13571357
pub struct rte_fdir_conf {
13581358
/// < Flow Director mode.
13591359
pub mode: rte_fdir_mode,
@@ -1411,7 +1411,7 @@ impl Default for rte_fdir_conf {
14111411
}
14121412
/// A structure used to enable/disable specific device interrupts.
14131413
#[repr(C)]
1414-
#[derive(Debug, Default, Copy, Hash, PartialEq)]
1414+
#[derive(Debug, Default, Copy, Hash, PartialEq, Eq)]
14151415
pub struct rte_intr_conf {
14161416
/// enable/disable lsc interrupt. 0 (default) - disable, 1 enable
14171417
pub lsc: u16,

tests/expectations/tests/layout_eth_conf_1_0.rs

Lines changed: 19 additions & 18 deletions
Original file line numberDiff line numberDiff line change
@@ -34,6 +34,7 @@ impl <T> ::std::hash::Hash for __BindgenUnionField<T> {
3434
impl <T> ::std::cmp::PartialEq for __BindgenUnionField<T> {
3535
fn eq(&self, _other: &__BindgenUnionField<T>) -> bool { true }
3636
}
37+
impl <T> ::std::cmp::Eq for __BindgenUnionField<T> { }
3738
pub const ETH_MQ_RX_RSS_FLAG: ::std::os::raw::c_uint = 1;
3839
pub const ETH_MQ_RX_DCB_FLAG: ::std::os::raw::c_uint = 2;
3940
pub const ETH_MQ_RX_VMDQ_FLAG: ::std::os::raw::c_uint = 4;
@@ -82,7 +83,7 @@ pub enum rte_eth_rx_mq_mode {
8283
}
8384
/// A structure used to configure the RX features of an Ethernet port.
8485
#[repr(C)]
85-
#[derive(Debug, Copy, Hash, PartialEq)]
86+
#[derive(Debug, Copy, Hash, PartialEq, Eq)]
8687
pub struct rte_eth_rxmode {
8788
/// The multi-queue packet distribution mode to be used, e.g. RSS.
8889
pub mq_mode: rte_eth_rx_mq_mode,
@@ -500,7 +501,7 @@ pub enum rte_eth_tx_mq_mode {
500501
}
501502
/// A structure used to configure the TX features of an Ethernet port.
502503
#[repr(C)]
503-
#[derive(Debug, Copy, Hash, PartialEq)]
504+
#[derive(Debug, Copy, Hash, PartialEq, Eq)]
504505
pub struct rte_eth_txmode {
505506
/// < TX multi-queues mode.
506507
pub mq_mode: rte_eth_tx_mq_mode,
@@ -671,7 +672,7 @@ impl rte_eth_txmode {
671672
/// types of IPv4/IPv6 packets to which the RSS hashing must be applied.
672673
/// Supplying an *rss_hf* equal to zero disables the RSS feature.
673674
#[repr(C)]
674-
#[derive(Debug, Copy, Hash, PartialEq)]
675+
#[derive(Debug, Copy, Hash, PartialEq, Eq)]
675676
pub struct rte_eth_rss_conf {
676677
/// < If not NULL, 40-byte hash key.
677678
pub rss_key: *mut u8,
@@ -748,7 +749,7 @@ pub struct rte_eth_vmdq_dcb_conf {
748749
pub dcb_tc: [u8; 8usize],
749750
}
750751
#[repr(C)]
751-
#[derive(Debug, Default, Copy, Hash, PartialEq)]
752+
#[derive(Debug, Default, Copy, Hash, PartialEq, Eq)]
752753
pub struct rte_eth_vmdq_dcb_conf__bindgen_ty_1 {
753754
/// < The vlan id of the received frame
754755
pub vlan_id: u16,
@@ -828,7 +829,7 @@ impl Default for rte_eth_vmdq_dcb_conf {
828829
fn default() -> Self { unsafe { ::std::mem::zeroed() } }
829830
}
830831
#[repr(C)]
831-
#[derive(Debug, Copy, Hash, PartialEq)]
832+
#[derive(Debug, Copy, Hash, PartialEq, Eq)]
832833
pub struct rte_eth_dcb_rx_conf {
833834
/// < Possible DCB TCs, 4 or 8 TCs
834835
pub nb_tcs: rte_eth_nb_tcs,
@@ -860,7 +861,7 @@ impl Default for rte_eth_dcb_rx_conf {
860861
fn default() -> Self { unsafe { ::std::mem::zeroed() } }
861862
}
862863
#[repr(C)]
863-
#[derive(Debug, Copy, Hash, PartialEq)]
864+
#[derive(Debug, Copy, Hash, PartialEq, Eq)]
864865
pub struct rte_eth_vmdq_dcb_tx_conf {
865866
/// < With DCB, 16 or 32 pools.
866867
pub nb_queue_pools: rte_eth_nb_pools,
@@ -894,7 +895,7 @@ impl Default for rte_eth_vmdq_dcb_tx_conf {
894895
fn default() -> Self { unsafe { ::std::mem::zeroed() } }
895896
}
896897
#[repr(C)]
897-
#[derive(Debug, Copy, Hash, PartialEq)]
898+
#[derive(Debug, Copy, Hash, PartialEq, Eq)]
898899
pub struct rte_eth_dcb_tx_conf {
899900
/// < Possible DCB TCs, 4 or 8 TCs.
900901
pub nb_tcs: rte_eth_nb_tcs,
@@ -926,7 +927,7 @@ impl Default for rte_eth_dcb_tx_conf {
926927
fn default() -> Self { unsafe { ::std::mem::zeroed() } }
927928
}
928929
#[repr(C)]
929-
#[derive(Debug, Copy, Hash, PartialEq)]
930+
#[derive(Debug, Copy, Hash, PartialEq, Eq)]
930931
pub struct rte_eth_vmdq_tx_conf {
931932
/// < VMDq mode, 64 pools.
932933
pub nb_queue_pools: rte_eth_nb_pools,
@@ -969,7 +970,7 @@ pub struct rte_eth_vmdq_rx_conf {
969970
pub pool_map: [rte_eth_vmdq_rx_conf__bindgen_ty_1; 64usize],
970971
}
971972
#[repr(C)]
972-
#[derive(Debug, Default, Copy, Hash, PartialEq)]
973+
#[derive(Debug, Default, Copy, Hash, PartialEq, Eq)]
973974
pub struct rte_eth_vmdq_rx_conf__bindgen_ty_1 {
974975
/// < The vlan id of the received frame
975976
pub vlan_id: u16,
@@ -1082,7 +1083,7 @@ pub enum rte_fdir_status_mode {
10821083
}
10831084
/// A structure used to define the input for IPV4 flow
10841085
#[repr(C)]
1085-
#[derive(Debug, Default, Copy, Hash, PartialEq)]
1086+
#[derive(Debug, Default, Copy, Hash, PartialEq, Eq)]
10861087
pub struct rte_eth_ipv4_flow {
10871088
/// < IPv4 source address in big endian.
10881089
pub src_ip: u32,
@@ -1132,7 +1133,7 @@ impl Clone for rte_eth_ipv4_flow {
11321133
}
11331134
/// A structure used to define the input for IPV6 flow
11341135
#[repr(C)]
1135-
#[derive(Debug, Default, Copy, Hash, PartialEq)]
1136+
#[derive(Debug, Default, Copy, Hash, PartialEq, Eq)]
11361137
pub struct rte_eth_ipv6_flow {
11371138
/// < IPv6 source address in big endian.
11381139
pub src_ip: [u32; 4usize],
@@ -1183,7 +1184,7 @@ impl Clone for rte_eth_ipv6_flow {
11831184
/// A structure used to configure FDIR masks that are used by the device
11841185
/// to match the various fields of RX packet headers.
11851186
#[repr(C)]
1186-
#[derive(Debug, Default, Copy, Hash, PartialEq)]
1187+
#[derive(Debug, Default, Copy, Hash, PartialEq, Eq)]
11871188
pub struct rte_eth_fdir_masks {
11881189
/// < Bit mask for vlan_tci in big endian
11891190
pub vlan_tci_mask: u16,
@@ -1269,7 +1270,7 @@ pub enum rte_eth_payload_type {
12691270
/// A structure used to select bytes extracted from the protocol layers to
12701271
/// flexible payload for filter
12711272
#[repr(C)]
1272-
#[derive(Debug, Copy, Hash, PartialEq)]
1273+
#[derive(Debug, Copy, Hash, PartialEq, Eq)]
12731274
pub struct rte_eth_flex_payload_cfg {
12741275
/// < Payload type
12751276
pub type_: rte_eth_payload_type,
@@ -1304,7 +1305,7 @@ impl Default for rte_eth_flex_payload_cfg {
13041305
/// A structure used to define FDIR masks for flexible payload
13051306
/// for each flow type
13061307
#[repr(C)]
1307-
#[derive(Debug, Default, Copy, Hash, PartialEq)]
1308+
#[derive(Debug, Default, Copy, Hash, PartialEq, Eq)]
13081309
pub struct rte_eth_fdir_flex_mask {
13091310
pub flow_type: u16,
13101311
pub mask: [u8; 16usize],
@@ -1334,7 +1335,7 @@ impl Clone for rte_eth_fdir_flex_mask {
13341335
/// A structure used to define all flexible payload related setting
13351336
/// include flex payload and flex mask
13361337
#[repr(C)]
1337-
#[derive(Debug, Copy, Hash, PartialEq)]
1338+
#[derive(Debug, Copy, Hash, PartialEq, Eq)]
13381339
pub struct rte_eth_fdir_flex_conf {
13391340
/// < The number of following payload cfg
13401341
pub nb_payloads: u16,
@@ -1383,7 +1384,7 @@ impl Default for rte_eth_fdir_flex_conf {
13831384
///
13841385
/// If mode is RTE_FDIR_DISABLE, the pballoc value is ignored.
13851386
#[repr(C)]
1386-
#[derive(Debug, Copy, Hash, PartialEq)]
1387+
#[derive(Debug, Copy, Hash, PartialEq, Eq)]
13871388
pub struct rte_fdir_conf {
13881389
/// < Flow Director mode.
13891390
pub mode: rte_fdir_mode,
@@ -1441,7 +1442,7 @@ impl Default for rte_fdir_conf {
14411442
}
14421443
/// A structure used to enable/disable specific device interrupts.
14431444
#[repr(C)]
1444-
#[derive(Debug, Default, Copy, Hash, PartialEq)]
1445+
#[derive(Debug, Default, Copy, Hash, PartialEq, Eq)]
14451446
pub struct rte_intr_conf {
14461447
/// enable/disable lsc interrupt. 0 (default) - disable, 1 enable
14471448
pub lsc: u16,
@@ -1554,7 +1555,7 @@ impl Default for rte_eth_conf__bindgen_ty_1 {
15541555
fn default() -> Self { unsafe { ::std::mem::zeroed() } }
15551556
}
15561557
#[repr(C)]
1557-
#[derive(Debug, Default, Copy, Hash, PartialEq)]
1558+
#[derive(Debug, Default, Copy, Hash, PartialEq, Eq)]
15581559
pub struct rte_eth_conf__bindgen_ty_2 {
15591560
pub vmdq_dcb_tx_conf: __BindgenUnionField<rte_eth_vmdq_dcb_tx_conf>,
15601561
pub dcb_tx_conf: __BindgenUnionField<rte_eth_dcb_tx_conf>,

0 commit comments

Comments
 (0)