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
Change Callbacks
API.
#2766
base: main
Are you sure you want to change the base?
Change Callbacks
API.
#2766
Conversation
de17fc8
to
aba0479
Compare
d4984df
to
2443850
Compare
8b65527
to
0600260
Compare
bindgen/ir/context.rs
Outdated
@@ -2159,8 +2159,8 @@ If you encounter an error missing from this list, please file an issue or a PR!" | |||
let mut kind = ModuleKind::Normal; | |||
let mut looking_for_name = false; | |||
for token in cursor.tokens().iter() { | |||
match token.spelling() { | |||
b"inline" => { | |||
match token.spelling().to_str().unwrap() { |
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.
What guarantees that the tokens are utf-8? I think the previous code was fine.
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.
We already assume UTF-8 in a bunch of other places, e.g. macro names and variable names. Granted here it's more for consistency rather than necessity.
bindgen/ir/var.rs
Outdated
let mut tokens = tokens | ||
.iter() | ||
.map(|token| token.spelling().to_str().unwrap()) | ||
.collect::<Vec<_>>(); |
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.
Same questions, I'd rather avoid crashing for non-utf8 input and just expose bytes?
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.
This is simply extracted from #2369 in order to be able to use cmacro
.
cmacro
needs to assume a single encoding to correctly parse macros. The same is true for users that implement ParseCallbacks::fn_macro
, they cannot just guess the encoding without knowing which file the byte slice came from.
I guess we can just skip macros containing invalid UTF-8 for now, though.
8178f51
to
ba72f63
Compare
@emilio, changed the code to skip non-UTF-8 items instead of crashing. |
ba72f63
to
11b0789
Compare
2bac4dd
to
8e200cd
Compare
@emilio, can you have a look here again? Thanks. |
8e200cd
to
80af414
Compare
☔ The latest upstream changes (presumably 770abd9) made this pull request unmergeable. Please resolve the merge conflicts. |
Extracted from #2369 for easier review.
Also apply
#[allow(unused_variables)]
everywhere to show nicer argument names in docs.