Skip to content
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 flag to ignore type blocklist when computing derive information #2003

Merged
merged 2 commits into from
Mar 11, 2021

Conversation

jethrogb
Copy link
Contributor

@jethrogb jethrogb commented Mar 9, 2021

Fixes #1454

I also prototyped adding the following method to ParseCallbacks but I think this PR is nicer:

/// This will be called to determine whether a particular blocklisted type
/// implements a trait or not. This will be used to implement traits on
/// other types containing the blocklisted type.
///
/// * `None`: use the default behavior
/// * `Some(true)`: `_name` implements `_derive_trait`
/// * `Some(false)`: `_name` doesn't implement `_derive_trait`
fn blocklisted_type_implements_trait(
    &self,
    _name: &str,
    _derive_trait: DeriveTrait
) -> Option<bool>;

@highfive
Copy link

highfive commented Mar 9, 2021

warning Warning warning

  • These commits modify unsafe code. Please review it carefully!

@jethrogb
Copy link
Contributor Author

This PR may not be sufficient, will provide additional tests later.

@jethrogb
Copy link
Contributor Author

So the main problem is that when using external crates to provide Rust definitions as in #1454 (comment), bindgen can't know what traits are/aren't implemented by those crates. I don't think there's a way around implementing blocklisted_type_implements_trait for a comprehensive solution.

jethrogb pushed a commit to jethrogb/rust-bindgen that referenced this pull request Mar 10, 2021
jethrogb pushed a commit to jethrogb/rust-bindgen that referenced this pull request Mar 10, 2021
jethrogb pushed a commit to jethrogb/rust-bindgen that referenced this pull request Mar 10, 2021
Copy link
Contributor

@emilio emilio left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Looks good, thanks!

@emilio emilio merged commit 7286c81 into rust-lang:master Mar 11, 2021
@jethrogb
Copy link
Contributor Author

Uh sorry but this was not meant to be merged anymore, see my last comment.

@emilio
Copy link
Contributor

emilio commented Mar 11, 2021

Ah, I assumed that given the other patches and this was open, it was intended to be merged after all. I'll revert, thanks.

emilio added a commit that referenced this pull request Mar 11, 2021
…mation"

This reverts commit 7286c81, because it
was not intended to be merged after all, see
#2003 (comment).
jethrogb pushed a commit to jethrogb/rust-bindgen that referenced this pull request Mar 16, 2021
jethrogb pushed a commit to jethrogb/rust-bindgen that referenced this pull request Mar 22, 2021
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

Successfully merging this pull request may close these issues.

Copy not derived when using whitelist_recursively(false)
3 participants