Skip to content

Commit ff21cdb

Browse files
committed
Add a test for blacklisting and deriving PartialEq
1 parent 530694c commit ff21cdb

File tree

2 files changed

+41
-0
lines changed

2 files changed

+41
-0
lines changed
Lines changed: 30 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,30 @@
1+
/* automatically generated by rust-bindgen */
2+
3+
4+
#![allow(dead_code, non_snake_case, non_camel_case_types, non_upper_case_globals)]
5+
6+
pub struct BlacklistMe(u8);
7+
8+
/// Because this type contains a blacklisted type, it should not derive
9+
/// PartialEq.
10+
#[repr(C)]
11+
pub struct ShouldNotDerivePartialEq {
12+
pub a: BlacklistMe,
13+
}
14+
#[test]
15+
fn bindgen_test_layout_ShouldNotDerivePartialEq() {
16+
assert_eq!(::std::mem::size_of::<ShouldNotDerivePartialEq>() , 1usize ,
17+
concat ! (
18+
"Size of: " , stringify ! ( ShouldNotDerivePartialEq ) ));
19+
assert_eq! (::std::mem::align_of::<ShouldNotDerivePartialEq>() , 1usize ,
20+
concat ! (
21+
"Alignment of " , stringify ! ( ShouldNotDerivePartialEq ) ));
22+
assert_eq! (unsafe {
23+
& ( * ( 0 as * const ShouldNotDerivePartialEq ) ) . a as *
24+
const _ as usize } , 0usize , concat ! (
25+
"Alignment of field: " , stringify ! (
26+
ShouldNotDerivePartialEq ) , "::" , stringify ! ( a ) ));
27+
}
28+
impl Default for ShouldNotDerivePartialEq {
29+
fn default() -> Self { unsafe { ::std::mem::zeroed() } }
30+
}
Lines changed: 11 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,11 @@
1+
// bindgen-flags: --with-derive-partialeq --blacklist-type BlacklistMe --raw-line 'pub struct BlacklistMe(u8);'
2+
3+
struct BlacklistMe {};
4+
5+
/**
6+
* Because this type contains a blacklisted type, it should not derive
7+
* PartialEq.
8+
*/
9+
struct ShouldNotDerivePartialEq {
10+
BlacklistMe a;
11+
};

0 commit comments

Comments
 (0)