-
Notifications
You must be signed in to change notification settings - Fork 694
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- [x] Add a new RegexSet member to bindgen::Builder (similar to the whitelisted_types set). - [x] A Builder method to add strings to that RegexSet. - [x] Plumbing in src/options.rs to convert --no-partialeq <regex> CLI flags into invocations of the builder method. - [x] Make the MonotoneFramework::constrain function in src/ir/analysis/derive_partialeq.rs check if the given item is explicitly marked not to be Partialeq, and if so, insert it into the self.cannot_derive_partialeq set via return self.insert(id). - [x] Tests! - [x] When the no-partialeq type is transitively referenced by a whitelisted item - [x] When the no-partialeq type is explicitly whitelisted - [x] When the no-partialeq type is marked opaque Fixes #965
- Loading branch information
Showing
10 changed files
with
197 additions
and
0 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
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,29 @@ | ||
/* automatically generated by rust-bindgen */ | ||
|
||
|
||
#![allow(dead_code, non_snake_case, non_camel_case_types, non_upper_case_globals)] | ||
|
||
|
||
#[repr(C)] | ||
#[derive(Debug, Default, Copy)] | ||
pub struct NoPartialEq { | ||
pub _bindgen_opaque_blob: u32, | ||
} | ||
#[test] | ||
fn bindgen_test_layout_NoPartialEq() { | ||
assert_eq!( | ||
::std::mem::size_of::<NoPartialEq>(), | ||
4usize, | ||
concat!("Size of: ", stringify!(NoPartialEq)) | ||
); | ||
assert_eq!( | ||
::std::mem::align_of::<NoPartialEq>(), | ||
4usize, | ||
concat!("Alignment of ", stringify!(NoPartialEq)) | ||
); | ||
} | ||
impl Clone for NoPartialEq { | ||
fn clone(&self) -> Self { | ||
*self | ||
} | ||
} |
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,39 @@ | ||
/* automatically generated by rust-bindgen */ | ||
|
||
|
||
#![allow(dead_code, non_snake_case, non_camel_case_types, non_upper_case_globals)] | ||
|
||
|
||
#[repr(C)] | ||
#[derive(Debug, Default, Copy)] | ||
pub struct NoPartialEq { | ||
pub i: ::std::os::raw::c_int, | ||
} | ||
#[test] | ||
fn bindgen_test_layout_NoPartialEq() { | ||
assert_eq!( | ||
::std::mem::size_of::<NoPartialEq>(), | ||
4usize, | ||
concat!("Size of: ", stringify!(NoPartialEq)) | ||
); | ||
assert_eq!( | ||
::std::mem::align_of::<NoPartialEq>(), | ||
4usize, | ||
concat!("Alignment of ", stringify!(NoPartialEq)) | ||
); | ||
assert_eq!( | ||
unsafe { &(*(0 as *const NoPartialEq)).i as *const _ as usize }, | ||
0usize, | ||
concat!( | ||
"Alignment of field: ", | ||
stringify!(NoPartialEq), | ||
"::", | ||
stringify!(i) | ||
) | ||
); | ||
} | ||
impl Clone for NoPartialEq { | ||
fn clone(&self) -> Self { | ||
*self | ||
} | ||
} |
62 changes: 62 additions & 0 deletions
62
tests/expectations/tests/whitelisted-item-references-no-partialeq.rs
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,62 @@ | ||
/* automatically generated by rust-bindgen */ | ||
|
||
|
||
#![allow(dead_code, non_snake_case, non_camel_case_types, non_upper_case_globals)] | ||
|
||
|
||
#[repr(C)] | ||
#[derive(Debug, Default, Copy)] | ||
pub struct NoPartialEq { | ||
pub _address: u8, | ||
} | ||
#[test] | ||
fn bindgen_test_layout_NoPartialEq() { | ||
assert_eq!( | ||
::std::mem::size_of::<NoPartialEq>(), | ||
1usize, | ||
concat!("Size of: ", stringify!(NoPartialEq)) | ||
); | ||
assert_eq!( | ||
::std::mem::align_of::<NoPartialEq>(), | ||
1usize, | ||
concat!("Alignment of ", stringify!(NoPartialEq)) | ||
); | ||
} | ||
impl Clone for NoPartialEq { | ||
fn clone(&self) -> Self { | ||
*self | ||
} | ||
} | ||
#[repr(C)] | ||
#[derive(Debug, Default, Copy)] | ||
pub struct WhitelistMe { | ||
pub a: NoPartialEq, | ||
} | ||
#[test] | ||
fn bindgen_test_layout_WhitelistMe() { | ||
assert_eq!( | ||
::std::mem::size_of::<WhitelistMe>(), | ||
1usize, | ||
concat!("Size of: ", stringify!(WhitelistMe)) | ||
); | ||
assert_eq!( | ||
::std::mem::align_of::<WhitelistMe>(), | ||
1usize, | ||
concat!("Alignment of ", stringify!(WhitelistMe)) | ||
); | ||
assert_eq!( | ||
unsafe { &(*(0 as *const WhitelistMe)).a as *const _ as usize }, | ||
0usize, | ||
concat!( | ||
"Alignment of field: ", | ||
stringify!(WhitelistMe), | ||
"::", | ||
stringify!(a) | ||
) | ||
); | ||
} | ||
impl Clone for WhitelistMe { | ||
fn clone(&self) -> Self { | ||
*self | ||
} | ||
} |
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,5 @@ | ||
// bindgen-flags: --with-derive-partialeq --opaque-type "NoPartialEq" --no-partialeq "NoPartialEq" | ||
|
||
class NoPartialEq { | ||
int i; | ||
}; |
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,5 @@ | ||
// bindgen-flags: --with-derive-partialeq --whitelist-type "NoPartialEq" --no-partialeq "NoPartialEq" | ||
|
||
class NoPartialEq { | ||
int i; | ||
}; |
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,7 @@ | ||
// bindgen-flags: --with-derive-partialeq --whitelist-type "WhitelistMe" --no-partialeq "NoPartialEq" | ||
|
||
struct NoPartialEq {}; | ||
|
||
class WhitelistMe { | ||
NoPartialEq a; | ||
}; |