-
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
Canonicalize a type (pointer type) first before checking for constness #1311
Merged
Merged
Changes from all commits
Commits
Show all changes
4 commits
Select commit
Hold shift + click to select a range
File filter
Filter by extension
Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
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,20 @@ | ||
/* automatically generated by rust-bindgen */ | ||
|
||
#![allow(dead_code, non_snake_case, non_camel_case_types, non_upper_case_globals)] | ||
|
||
extern "C" { | ||
#[link_name = "\u{1}a"] | ||
pub static mut a: *mut ::std::os::raw::c_char; | ||
} | ||
extern "C" { | ||
#[link_name = "\u{1}b"] | ||
pub static mut b: *const ::std::os::raw::c_char; | ||
} | ||
extern "C" { | ||
#[link_name = "\u{1}c"] | ||
pub static mut c: *mut ::std::os::raw::c_char; | ||
} | ||
extern "C" { | ||
#[link_name = "\u{1}d"] | ||
pub static mut d: *const ::std::os::raw::c_char; | ||
} |
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,4 @@ | ||
char * a; | ||
const char * b; | ||
char * const c; | ||
const char * const d; |
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
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.
I think this works, but instead the better fix is (I think), changing the following line:
https://github.com/rust-lang-nursery/rust-bindgen/blob/515ca97b462f348b7b3bb9eaea98b2e0bb1b624b/src/codegen/mod.rs#L3057
To not check
self.is_const()
, pointing out that pointer-constness itself can't be represented in rust.Or in any case that line could be cleaned up.
I think handling it in codegen is better though, since there are a couple other places where we use libclang's is_const in
context.rs
.Also, could you test this with constants? This would solve #511. The test-case in that issue's description is pretty good.
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.
Mhhh. It's somewhat strange, I tried to apply your suggestion but I am getting test failures. It seems that
ctx.resolve_type(inner)
resolves to an opaque type? I am not sure though, I didn't have much time to debug this (I guess, I'll give it another shot later today).But this PR should also fix #511 (Well, it seems like it).
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.
If you get stuck let me know, we can merge this for now and I can take a look at that more carefully. Please do file an issue for that if we leave it as a followup and add the tests for #511 if you can though.
Thank you!
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.
Yeah, I think that's best for now. I'll create a new issue after this PR is merged.
I've also pushed the test from issue #511.