-
Notifications
You must be signed in to change notification settings - Fork 747
clang::TranslationUnit::parse should return Option<TranslationUnit> #144
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
Comments
Please make a comment here if you intend to work on this issue. Thank you! |
I'd like to have a go at this but could use some help as I've never written Rust before. I know how to return I can imagine either throwing some sort of error on receipt of |
Hi! This would involve changing the function signature from As for callers, you are right that they currently assume that they get back a valid translation unit. We can let them keep that expectation, and safely+loudly panic when that expectation is not met. We could do that by calling either Does that make sense? |
I think so. does this look about right? https://github.com/igilham/rust-bindgen/commit/362eac2b12568428637b7cdf091db3fbc9d46c00 |
Yeah! That looks great! Does it compile and do the tests pass? If so, sounds like it's time to open a PR! If not, I can help figure out what's going on, if needed. |
Hmm... looks like the tests didn't pass to begin with (on this machine anyway). Here's the log of the previous master commit before my changes. I'm running on OS X 10.10.5 with LLVM 3.9. Does this seem familiar?
|
Hmmm... The tests pass on master for me on OSX 10.11.6 and on Fedora 24, both with llvm 3.9. Can you open a PR so we can see what Travis CI says and I can more easily pull down your changes locally? |
Sure, I'll give it a try. It may just be an environment configuration issue. |
Are running the tests with |
I can check that tomorrow. I left that machine at the office. |
Travis seems to like it. I'll see if I can figure out the test environment when the opportunity arises. |
Changed the potentially null pointer to an Optional. The caller previously assumed the pointer was always valid and not null, so I called `expect` to make it fail early if it isn't. Fixes #144.
The
parse
method does an FFI call toclang_parseTranslationUnit
which returns the "null" translation unit if parsing failed. We don't currently check that result, forcing callers to remember to check it, which is a foot gun. Instead, we should check it in this method and returnNone
if parsing failed, orSome
if it succeeded.I can mentor whoever would like to work on this.
The text was updated successfully, but these errors were encountered: