forked from rust-lang/rust-bindgen
-
Notifications
You must be signed in to change notification settings - Fork 0
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Add callback to check derives for blocklisted types
Fixes rust-lang#1454 rust-lang#2003
- Loading branch information
Jethro Beekman
committed
Mar 16, 2021
1 parent
7b3e7d1
commit 447923b
Showing
6 changed files
with
148 additions
and
9 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,41 @@ | ||
#![allow( | ||
dead_code, | ||
non_snake_case, | ||
non_camel_case_types, | ||
non_upper_case_globals | ||
)] | ||
|
||
#[repr(C)] | ||
#[derive(Debug)] | ||
pub struct extern_type; | ||
|
||
#[repr(C)] | ||
#[derive(Debug)] | ||
pub struct local_type { | ||
pub inner: extern_type, | ||
} | ||
#[test] | ||
fn bindgen_test_layout_local_type() { | ||
assert_eq!( | ||
::std::mem::size_of::<local_type>(), | ||
0usize, | ||
concat!("Size of: ", stringify!(local_type)) | ||
); | ||
assert_eq!( | ||
::std::mem::align_of::<local_type>(), | ||
1usize, | ||
concat!("Alignment of ", stringify!(local_type)) | ||
); | ||
assert_eq!( | ||
unsafe { | ||
&(*(::std::ptr::null::<local_type>())).inner as *const _ as usize | ||
}, | ||
0usize, | ||
concat!( | ||
"Offset of field: ", | ||
stringify!(local_type), | ||
"::", | ||
stringify!(inner) | ||
) | ||
); | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,10 @@ | ||
// bindgen-flags: --no-recursive-allowlist --allowlist-type "local_type" --with-derive-hash --no-derive-copy --no-derive-default --raw-line "#[repr(C)] #[derive(Debug)] pub struct extern_type;" | ||
// bindgen-parse-callbacks: blocklisted-type-implements-trait | ||
|
||
struct extern_type {}; | ||
|
||
typedef struct | ||
{ | ||
struct extern_type inner; | ||
} | ||
local_type; |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters