-
Notifications
You must be signed in to change notification settings - Fork 707
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Add --no-partialeq <regex> flag #996
Add --no-partialeq <regex> flag #996
Conversation
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Yep! This looks like what I would expect it to. You're on the right path :)
src/ir/analysis/derive_partial_eq.rs
Outdated
@@ -144,6 +145,11 @@ impl<'ctx> MonotoneFramework for CannotDerivePartialEq<'ctx> { | |||
}; | |||
} | |||
|
|||
let name = item.canonical_name(self.ctx); | |||
if self.ctx.options().no_partialeq_types.matches(&name) { |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Let's abstract this check into a BindgenContext::no_partialeq_by_name
, similar to BindgenContext::is_opaque_by_name
and BindgenContext::is_blacklisted_by_name
.
☔ The latest upstream changes (presumably #1000) made this pull request unmergeable. Please resolve the merge conflicts. |
7c8f70b
to
e838a12
Compare
r? @fitzgen |
It makes sense that opaque types still The explicitly whitelisted types always getting |
Hm yeah the test headers look how I'd expect them to, but the generated bindings don't. I'd try adding some debug
If you still can't figure out what's going on after that, I can try pulling these changes down myself and investigating. BTW, I'm not sure if you're aware that the "impl period" has just begun, but the folks hacking on |
☔ The latest upstream changes (presumably #1002) made this pull request unmergeable. Please resolve the merge conflicts. |
I've tried it just now, but the result is still the same. Makes me wonder if Thanks for the invite! :) |
067c57b
to
2bcf255
Compare
- [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 rust-lang#965
a6eadb4
to
ec8456b
Compare
@bors-servo r+ Thanks @alexeyzab ! |
📌 Commit ec8456b has been approved by |
Add --no-partialeq <regex> flag Related to #965. - [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 This is my first pass at implementing this functionality, I haven't implemented the tests yet. I wanted to make sure I am on the right track, particularly when it comes to updating `MonotoneFramework::constrain`. r? @fitzgen
☀️ Test successful - status-travis |
Related to #965.
Add a new RegexSet member to bindgen::Builder (similar to the whitelisted_types set).
A Builder method to add strings to that RegexSet.
Plumbing in src/options.rs to convert --no-partialeq CLI flags into invocations of the builder method.
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).
Tests!
When the no-partialeq type is transitively referenced by a whitelisted item
When the no-partialeq type is explicitly whitelisted
When the no-partialeq type is marked opaque
This is my first pass at implementing this functionality, I haven't implemented the tests yet. I wanted to make sure I am on the right track, particularly when it comes to updating
MonotoneFramework::constrain
.r? @fitzgen