Skip to content

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

Closed
fitzgen opened this issue Oct 25, 2016 · 11 comments
Closed

clang::TranslationUnit::parse should return Option<TranslationUnit> #144

fitzgen opened this issue Oct 25, 2016 · 11 comments

Comments

@fitzgen
Copy link
Member

fitzgen commented Oct 25, 2016

The parse method does an FFI call to clang_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 return None if parsing failed, or Some if it succeeded.

I can mentor whoever would like to work on this.

@highfive
Copy link

Please make a comment here if you intend to work on this issue. Thank you!

@igilham
Copy link

igilham commented Oct 27, 2016

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 Option<TranslationUnit> but don't really know how to handle it in calling classes. The docs for Option are good, but I could use a little help understanding the semantics of the caller. It looks like the caller currently assumes the pointer is not null and just runs with it (see src/ir/context.rs:106, 685).

I can imagine either throwing some sort of error on receipt of None or stuffing the Option into the struct that currently contains the TranslationUnit then handling it in the various places it is used. Is the BindgenContext in a valid state if it contains a None value and we keep executing?

@fitzgen
Copy link
Member Author

fitzgen commented Oct 27, 2016

Hi!

This would involve changing the function signature from -> TranslationUnit to -> Option<TranslationUnit>.

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 .unwrap() or .expect("diagnostic message blah blah") on the returned Option value to get the underlying Some value, or panicking when the Option is a None.

Does that make sense?

@igilham
Copy link

igilham commented Oct 27, 2016

@fitzgen
Copy link
Member Author

fitzgen commented Oct 27, 2016

I think so. does this look about right?

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.

@igilham
Copy link

igilham commented Oct 27, 2016

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?

Running target/debug/tests-f239832665bb002e

running 1 test
test run_bindgen_tests ... FAILED

failures:

---- run_bindgen_tests stdout ----
    FAIL: /Users/gilhai01/code/rust-bindgen/tests/headers/jsval_layout_opaque.hpp
child stdout> run-bindgen.py: running ['/Users/gilhai01/code/rust-bindgen/target/debug/bindgen', '-o', '/Users/gilhai01/code/rust-bindgen/tests/expectations/jsval_layout_opaque.rs', '--no-unstable-rust', '--raw-line', '', '--raw-line', '#![allow(non_snake_case)]', '--raw-line', '', '--no-unstable-rust', '--', '-std=c++11', '/Users/gilhai01/code/rust-bindgen/tests/headers/jsval_layout_opaque.hpp']
child stderr> run-bindgen.py: running ['/Users/gilhai01/code/rust-bindgen/target/debug/bindgen', '-o', '/Users/gilhai01/code/rust-bindgen/tests/expectations/jsval_layout_opaque.rs', '--no-unstable-rust', '--raw-line', '', '--raw-line', '#![allow(non_snake_case)]', '--raw-line', '', '--no-unstable-rust', '--', '-std=c++11', '/Users/gilhai01/code/rust-bindgen/tests/headers/jsval_layout_opaque.hpp']
child stderr> ERROR:bindgen::ir::ty: invalid type Type(, kind: Invalid, decl: Cursor( kind: NoDeclFound, loc: builtin definitions, usr: None), canon: Cursor( kind: NoDeclFound, loc: builtin definitions, usr: None))
child stderr> ERROR:bindgen::ir::item: Unhandled cursor kind: MacroDefinition (501)
child stderr> ERROR:bindgen::ir::ty: invalid type Type(, kind: Invalid, decl: Cursor( kind: NoDeclFound, loc: builtin definitions, usr: None), canon: Cursor( kind: NoDeclFound, loc: builtin definitions, usr: None))
child stderr> ERROR:bindgen::ir::item: Unhandled cursor kind: MacroDefinition (501)
child stderr> ERROR:bindgen::ir::ty: invalid type Type(, kind: Invalid, decl: Cursor( kind: NoDeclFound, loc: builtin definitions, usr: None), canon: Cursor( kind: NoDeclFound, loc: builtin definitions, usr: None))
child stderr> ERROR:bindgen::ir::item: Unhandled cursor kind: MacroExpansion (502)
child stderr> ERROR:bindgen::ir::ty: invalid type Type(, kind: Invalid, decl: Cursor( kind: NoDeclFound, loc: builtin definitions, usr: None), canon: Cursor( kind: NoDeclFound, loc: builtin definitions, usr: None))
child stderr> ERROR:bindgen::ir::item: Unhandled cursor kind: MacroExpansion (502)
child stderr> ERROR:bindgen::ir::ty: invalid type Type(, kind: Invalid, decl: Cursor( kind: NoDeclFound, loc: builtin definitions, usr: None), canon: Cursor( kind: NoDeclFound, loc: builtin definitions, usr: None))
child stderr> ERROR:bindgen::ir::item: Unhandled cursor kind: MacroDefinition (501)
child stderr> ERROR:bindgen::ir::ty: invalid type Type(, kind: Invalid, decl: Cursor( kind: NoDeclFound, loc: builtin definitions, usr: None), canon: Cursor( kind: NoDeclFound, loc: builtin definitions, usr: None))
child stderr> ERROR:bindgen::ir::item: Unhandled cursor kind: MacroDefinition (501)
child stderr> ERROR:bindgen::ir::ty: invalid type Type(, kind: Invalid, decl: Cursor( kind: NoDeclFound, loc: builtin definitions, usr: None), canon: Cursor( kind: NoDeclFound, loc: builtin definitions, usr: None))
child stderr> ERROR:bindgen::ir::item: Unhandled cursor kind: MacroExpansion (502)
child stderr> ERROR:bindgen::ir::ty: invalid type Type(, kind: Invalid, decl: Cursor( kind: NoDeclFound, loc: builtin definitions, usr: None), canon: Cursor( kind: NoDeclFound, loc: builtin definitions, usr: None))
child stderr> ERROR:bindgen::ir::item: Unhandled cursor kind: MacroExpansion (502)
child stderr> ERROR:bindgen::ir::ty: invalid type Type(, kind: Invalid, decl: Cursor( kind: NoDeclFound, loc: builtin definitions, usr: None), canon: Cursor( kind: NoDeclFound, loc: builtin definitions, usr: None))
child stderr> ERROR:bindgen::ir::item: Unhandled cursor kind: MacroExpansion (502)
child stderr> ERROR:bindgen::ir::ty: invalid type Type(, kind: Invalid, decl: Cursor( kind: NoDeclFound, loc: builtin definitions, usr: None), canon: Cursor( kind: NoDeclFound, loc: builtin definitions, usr: None))
child stderr> ERROR:bindgen::ir::item: Unhandled cursor kind: MacroExpansion (502)
child stderr> ERROR:bindgen::ir::ty: invalid type Type(, kind: Invalid, decl: Cursor( kind: NoDeclFound, loc: builtin definitions, usr: None), canon: Cursor( kind: NoDeclFound, loc: builtin definitions, usr: None))
child stderr> ERROR:bindgen::ir::item: Unhandled cursor kind: MacroExpansion (502)
child stderr> ERROR:bindgen::ir::ty: invalid type Type(, kind: Invalid, decl: Cursor( kind: NoDeclFound, loc: builtin definitions, usr: None), canon: Cursor( kind: NoDeclFound, loc: builtin definitions, usr: None))
child stderr> ERROR:bindgen::ir::item: Unhandled cursor kind: MacroExpansion (502)
child stderr> ERROR:bindgen::ir::ty: invalid type Type(, kind: Invalid, decl: Cursor( kind: NoDeclFound, loc: builtin definitions, usr: None), canon: Cursor( kind: NoDeclFound, loc: builtin definitions, usr: None))
child stderr> ERROR:bindgen::ir::item: Unhandled cursor kind: MacroExpansion (502)
child stderr> ERROR:bindgen::ir::ty: invalid type Type(, kind: Invalid, decl: Cursor( kind: NoDeclFound, loc: builtin definitions, usr: None), canon: Cursor( kind: NoDeclFound, loc: builtin definitions, usr: None))
child stderr> ERROR:bindgen::ir::item: Unhandled cursor kind: MacroExpansion (502)
child stderr> ERROR:bindgen::ir::ty: invalid type Type(, kind: Invalid, decl: Cursor( kind: NoDeclFound, loc: builtin definitions, usr: None), canon: Cursor( kind: NoDeclFound, loc: builtin definitions, usr: None))
child stderr> ERROR:bindgen::ir::item: Unhandled cursor kind: MacroExpansion (502)
child stderr> ERROR:bindgen::ir::ty: invalid type Type(, kind: Invalid, decl: Cursor( kind: NoDeclFound, loc: builtin definitions, usr: None), canon: Cursor( kind: NoDeclFound, loc: builtin definitions, usr: None))
child stderr> ERROR:bindgen::ir::item: Unhandled cursor kind: MacroExpansion (502)
child stderr> ERROR:bindgen::ir::ty: invalid type Type(, kind: Invalid, decl: Cursor( kind: NoDeclFound, loc: builtin definitions, usr: None), canon: Cursor( kind: NoDeclFound, loc: builtin definitions, usr: None))
child stderr> ERROR:bindgen::ir::item: Unhandled cursor kind: MacroExpansion (502)
child stderr> ERROR:bindgen::ir::ty: invalid type Type(, kind: Invalid, decl: Cursor( kind: NoDeclFound, loc: builtin definitions, usr: None), canon: Cursor( kind: NoDeclFound, loc: builtin definitions, usr: None))
child stderr> ERROR:bindgen::ir::item: Unhandled cursor kind: MacroExpansion (502)
child stderr> ERROR:bindgen::ir::ty: invalid type Type(, kind: Invalid, decl: Cursor( kind: NoDeclFound, loc: builtin definitions, usr: None), canon: Cursor( kind: NoDeclFound, loc: builtin definitions, usr: None))
child stderr> ERROR:bindgen::ir::item: Unhandled cursor kind: MacroExpansion (502)
child stderr> ERROR:bindgen::ir::ty: invalid type Type(, kind: Invalid, decl: Cursor( kind: NoDeclFound, loc: builtin definitions, usr: None), canon: Cursor( kind: NoDeclFound, loc: builtin definitions, usr: None))
child stderr> ERROR:bindgen::ir::item: Unhandled cursor kind: MacroExpansion (502)
child stderr> ERROR:bindgen::ir::ty: invalid type Type(, kind: Invalid, decl: Cursor( kind: NoDeclFound, loc: builtin definitions, usr: None), canon: Cursor( kind: NoDeclFound, loc: builtin definitions, usr: None))
child stderr> ERROR:bindgen::ir::item: Unhandled cursor kind: MacroExpansion (502)
child stderr> ERROR:bindgen::ir::ty: invalid type Type(, kind: Invalid, decl: Cursor( kind: NoDeclFound, loc: builtin definitions, usr: None), canon: Cursor( kind: NoDeclFound, loc: builtin definitions, usr: None))
child stderr> ERROR:bindgen::ir::item: Unhandled cursor kind: MacroExpansion (502)
child stderr> ERROR:bindgen::ir::ty: invalid type Type(, kind: Invalid, decl: Cursor( kind: NoDeclFound, loc: builtin definitions, usr: None), canon: Cursor( kind: NoDeclFound, loc: builtin definitions, usr: None))
child stderr> ERROR:bindgen::ir::item: Unhandled cursor kind: MacroExpansion (502)
child stderr> ERROR:bindgen::ir::ty: invalid type Type(, kind: Invalid, decl: Cursor( kind: NoDeclFound, loc: builtin definitions, usr: None), canon: Cursor( kind: NoDeclFound, loc: builtin definitions, usr: None))
child stderr> ERROR:bindgen::ir::item: Unhandled cursor kind: MacroDefinition (501)
child stderr> ERROR:bindgen::ir::ty: invalid type Type(, kind: Invalid, decl: Cursor( kind: NoDeclFound, loc: builtin definitions, usr: None), canon: Cursor( kind: NoDeclFound, loc: builtin definitions, usr: None))
child stderr> ERROR:bindgen::ir::item: Unhandled cursor kind: MacroDefinition (501)
child stderr> ERROR:bindgen::ir::ty: invalid type Type(, kind: Invalid, decl: Cursor( kind: NoDeclFound, loc: builtin definitions, usr: None), canon: Cursor( kind: NoDeclFound, loc: builtin definitions, usr: None))
child stderr> ERROR:bindgen::ir::item: Unhandled cursor kind: MacroDefinition (501)
child stderr> ERROR:bindgen::ir::ty: invalid type Type(, kind: Invalid, decl: Cursor( kind: NoDeclFound, loc: builtin definitions, usr: None), canon: Cursor( kind: NoDeclFound, loc: builtin definitions, usr: None))
child stderr> ERROR:bindgen::ir::item: Unhandled cursor kind: MacroDefinition (501)
child stderr> ERROR:bindgen::ir::ty: invalid type Type(, kind: Invalid, decl: Cursor( kind: NoDeclFound, loc: builtin definitions, usr: None), canon: Cursor( kind: NoDeclFound, loc: builtin definitions, usr: None))
child stderr> ERROR:bindgen::ir::item: Unhandled cursor kind: MacroDefinition (501)
child stderr> ERROR:bindgen::ir::ty: invalid type Type(, kind: Invalid, decl: Cursor( kind: NoDeclFound, loc: builtin definitions, usr: None), canon: Cursor( kind: NoDeclFound, loc: builtin definitions, usr: None))
child stderr> ERROR:bindgen::ir::item: Unhandled cursor kind: MacroDefinition (501)
child stderr> ERROR:bindgen::ir::ty: invalid type Type(, kind: Invalid, decl: Cursor( kind: NoDeclFound, loc: builtin definitions, usr: None), canon: Cursor( kind: NoDeclFound, loc: builtin definitions, usr: None))
child stderr> ERROR:bindgen::ir::item: Unhandled cursor kind: MacroDefinition (501)
child stderr> ERROR:bindgen::ir::ty: invalid type Type(, kind: Invalid, decl: Cursor( kind: NoDeclFound, loc: builtin definitions, usr: None), canon: Cursor( kind: NoDeclFound, loc: builtin definitions, usr: None))
child stderr> ERROR:bindgen::ir::item: Unhandled cursor kind: MacroDefinition (501)
child stderr> ERROR:bindgen::ir::ty: invalid type Type(, kind: Invalid, decl: Cursor( kind: NoDeclFound, loc: builtin definitions, usr: None), canon: Cursor( kind: NoDeclFound, loc: builtin definitions, usr: None))
child stderr> ERROR:bindgen::ir::item: Unhandled cursor kind: MacroDefinition (501)
child stderr> ERROR:bindgen::ir::ty: invalid type Type(, kind: Invalid, decl: Cursor( kind: NoDeclFound, loc: builtin definitions, usr: None), canon: Cursor( kind: NoDeclFound, loc: builtin definitions, usr: None))
child stderr> ERROR:bindgen::ir::item: Unhandled cursor kind: MacroDefinition (501)
child stderr> ERROR:bindgen::ir::ty: invalid type Type(, kind: Invalid, decl: Cursor( kind: NoDeclFound, loc: builtin definitions, usr: None), canon: Cursor( kind: NoDeclFound, loc: builtin definitions, usr: None))
child stderr> ERROR:bindgen::ir::item: Unhandled cursor kind: MacroDefinition (501)
child stderr> ERROR:bindgen::ir::ty: invalid type Type(, kind: Invalid, decl: Cursor( kind: NoDeclFound, loc: builtin definitions, usr: None), canon: Cursor( kind: NoDeclFound, loc: builtin definitions, usr: None))
child stderr> ERROR:bindgen::ir::item: Unhandled cursor kind: MacroDefinition (501)
child stderr> ERROR:bindgen::ir::ty: invalid type Type(, kind: Invalid, decl: Cursor( kind: NoDeclFound, loc: builtin definitions, usr: None), canon: Cursor( kind: NoDeclFound, loc: builtin definitions, usr: None))
child stderr> ERROR:bindgen::ir::item: Unhandled cursor kind: MacroExpansion (502)
child stderr> ERROR:bindgen::ir::ty: invalid type Type(, kind: Invalid, decl: Cursor( kind: NoDeclFound, loc: builtin definitions, usr: None), canon: Cursor( kind: NoDeclFound, loc: builtin definitions, usr: None))
child stderr> ERROR:bindgen::ir::item: Unhandled cursor kind: MacroExpansion (502)
child stderr> ERROR:bindgen::ir::ty: invalid type Type(, kind: Invalid, decl: Cursor( kind: NoDeclFound, loc: builtin definitions, usr: None), canon: Cursor( kind: NoDeclFound, loc: builtin definitions, usr: None))
child stderr> ERROR:bindgen::ir::item: Unhandled cursor kind: MacroExpansion (502)
child stderr> ERROR:bindgen::ir::ty: invalid type Type(, kind: Invalid, decl: Cursor( kind: NoDeclFound, loc: builtin definitions, usr: None), canon: Cursor( kind: NoDeclFound, loc: builtin definitions, usr: None))
child stderr> ERROR:bindgen::ir::item: Unhandled cursor kind: MacroExpansion (502)
child stderr> ERROR:bindgen::ir::ty: invalid type Type(, kind: Invalid, decl: Cursor( kind: NoDeclFound, loc: builtin definitions, usr: None), canon: Cursor( kind: NoDeclFound, loc: builtin definitions, usr: None))
child stderr> ERROR:bindgen::ir::item: Unhandled cursor kind: MacroExpansion (502)
child stderr> ERROR:bindgen::ir::ty: invalid type Type(, kind: Invalid, decl: Cursor( kind: NoDeclFound, loc: builtin definitions, usr: None), canon: Cursor( kind: NoDeclFound, loc: builtin definitions, usr: None))
child stderr> ERROR:bindgen::ir::item: Unhandled cursor kind: MacroExpansion (502)
child stderr> ERROR:bindgen::ir::ty: invalid type Type(, kind: Invalid, decl: Cursor( kind: NoDeclFound, loc: builtin definitions, usr: None), canon: Cursor( kind: NoDeclFound, loc: builtin definitions, usr: None))
child stderr> ERROR:bindgen::ir::item: Unhandled cursor kind: MacroDefinition (501)
child stderr> ERROR:bindgen::ir::ty: invalid type Type(, kind: Invalid, decl: Cursor( kind: NoDeclFound, loc: builtin definitions, usr: None), canon: Cursor( kind: NoDeclFound, loc: builtin definitions, usr: None))
child stderr> ERROR:bindgen::ir::item: Unhandled cursor kind: MacroExpansion (502)
child stderr> ERROR:bindgen::ir::ty: invalid type Type(, kind: Invalid, decl: Cursor( kind: NoDeclFound, loc: builtin definitions, usr: None), canon: Cursor( kind: NoDeclFound, loc: builtin definitions, usr: None))
child stderr> ERROR:bindgen::ir::item: Unhandled cursor kind: MacroDefinition (501)
child stderr> ERROR:bindgen::ir::ty: invalid type Type(, kind: Invalid, decl: Cursor( kind: NoDeclFound, loc: builtin definitions, usr: None), canon: Cursor( kind: NoDeclFound, loc: builtin definitions, usr: None))
child stderr> ERROR:bindgen::ir::item: Unhandled cursor kind: MacroDefinition (501)
child stderr> ERROR:bindgen::ir::ty: invalid type Type(, kind: Invalid, decl: Cursor( kind: NoDeclFound, loc: builtin definitions, usr: None), canon: Cursor( kind: NoDeclFound, loc: builtin definitions, usr: None))
child stderr> ERROR:bindgen::ir::item: Unhandled cursor kind: MacroDefinition (501)
child stderr> ERROR:bindgen::ir::ty: invalid type Type(, kind: Invalid, decl: Cursor( kind: NoDeclFound, loc: builtin definitions, usr: None), canon: Cursor( kind: NoDeclFound, loc: builtin definitions, usr: None))
child stderr> ERROR:bindgen::ir::item: Unhandled cursor kind: StaticAssert (602)
child stderr> ERROR:bindgen::ir::ty: invalid type Type(, kind: Invalid, decl: Cursor( kind: NoDeclFound, loc: builtin definitions, usr: None), canon: Cursor( kind: NoDeclFound, loc: builtin definitions, usr: None))
child stderr> ERROR:bindgen::ir::item: Unhandled cursor kind: StaticAssert (602)
child stderr> ERROR:bindgen::ir::ty: invalid type Type(, kind: Invalid, decl: Cursor( kind: NoDeclFound, loc: builtin definitions, usr: None), canon: Cursor( kind: NoDeclFound, loc: builtin definitions, usr: None))
child stderr> ERROR:bindgen::ir::item: Unhandled cursor kind: StaticAssert (602)
child stderr> Traceback (most recent call last):
child stderr>   File "/Users/gilhai01/code/rust-bindgen/tests/tools/run-bindgen.py", line 190, in <module>
child stderr>     main()
child stderr>   File "/Users/gilhai01/code/rust-bindgen/tests/tools/run-bindgen.py", line 184, in main
child stderr>     generate_bindings(args.bindgen, test_flags, args.header, args.rust_bindings)
child stderr>   File "/Users/gilhai01/code/rust-bindgen/tests/tools/run-bindgen.py", line 137, in generate_bindings
child stderr>     run_cmd(command, cwd=os.getcwd(), env=make_bindgen_env())
child stderr>   File "/Users/gilhai01/code/rust-bindgen/tests/tools/run-bindgen.py", line 130, in run_cmd
child stderr>     subprocess.check_call(command, **kwargs)
child stderr>   File "/usr/local/Cellar/python/2.7.12_2/Frameworks/Python.framework/Versions/2.7/lib/python2.7/subprocess.py", line 541, in check_call
child stderr>     raise CalledProcessError(retcode, cmd)
child stderr> subprocess.CalledProcessError: Command '['/Users/gilhai01/code/rust-bindgen/target/debug/bindgen', '-o', '/Users/gilhai01/code/rust-bindgen/tests/expectations/jsval_layout_opaque.rs', '--no-unstable-rust', '--raw-line', '', '--raw-line', '#![allow(non_snake_case)]', '--raw-line', '', '--no-unstable-rust', '--', '-std=c++11', '/Users/gilhai01/code/rust-bindgen/tests/headers/jsval_layout_opaque.hpp']' returned non-zero exit status -11
FAIL: /Users/gilhai01/code/rust-bindgen/tests/headers/union_with_anon_struct_bitfield.h
child stdout> run-bindgen.py: running ['/Users/gilhai01/code/rust-bindgen/target/debug/bindgen', '-o', '/Users/gilhai01/code/rust-bindgen/tests/expectations/union_with_anon_struct_bitfield.rs', '--no-unstable-rust', '--raw-line', '', '--raw-line', '#![allow(non_snake_case)]', '--raw-line', '', '--no-unstable-rust', '/Users/gilhai01/code/rust-bindgen/tests/headers/union_with_anon_struct_bitfield.h']
child stderr> run-bindgen.py: running ['/Users/gilhai01/code/rust-bindgen/target/debug/bindgen', '-o', '/Users/gilhai01/code/rust-bindgen/tests/expectations/union_with_anon_struct_bitfield.rs', '--no-unstable-rust', '--raw-line', '', '--raw-line', '#![allow(non_snake_case)]', '--raw-line', '', '--no-unstable-rust', '/Users/gilhai01/code/rust-bindgen/tests/headers/union_with_anon_struct_bitfield.h']
child stderr> Traceback (most recent call last):
child stderr>   File "/Users/gilhai01/code/rust-bindgen/tests/tools/run-bindgen.py", line 190, in <module>
child stderr>     main()
child stderr>   File "/Users/gilhai01/code/rust-bindgen/tests/tools/run-bindgen.py", line 184, in main
child stderr>     generate_bindings(args.bindgen, test_flags, args.header, args.rust_bindings)
child stderr>   File "/Users/gilhai01/code/rust-bindgen/tests/tools/run-bindgen.py", line 137, in generate_bindings
child stderr>     run_cmd(command, cwd=os.getcwd(), env=make_bindgen_env())
child stderr>   File "/Users/gilhai01/code/rust-bindgen/tests/tools/run-bindgen.py", line 130, in run_cmd
child stderr>     subprocess.check_call(command, **kwargs)
child stderr>   File "/usr/local/Cellar/python/2.7.12_2/Frameworks/Python.framework/Versions/2.7/lib/python2.7/subprocess.py", line 541, in check_call
child stderr>     raise CalledProcessError(retcode, cmd)
child stderr> subprocess.CalledProcessError: Command '['/Users/gilhai01/code/rust-bindgen/target/debug/bindgen', '-o', '/Users/gilhai01/code/rust-bindgen/tests/expectations/union_with_anon_struct_bitfield.rs', '--no-unstable-rust', '--raw-line', '', '--raw-line', '#![allow(non_snake_case)]', '--raw-line', '', '--no-unstable-rust', '/Users/gilhai01/code/rust-bindgen/tests/headers/union_with_anon_struct_bitfield.h']' returned non-zero exit status -11
thread 'run_bindgen_tests' panicked at '2 test failures!', tests/tests.rs:132
note: Run with `RUST_BACKTRACE=1` for a backtrace.


failures:
    run_bindgen_tests

test result: FAILED. 0 passed; 1 failed; 0 ignored; 0 measured

error: test failed

@fitzgen
Copy link
Member Author

fitzgen commented Oct 27, 2016

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?

@igilham
Copy link

igilham commented Oct 27, 2016

Sure, I'll give it a try. It may just be an environment configuration issue.

@fitzgen
Copy link
Member Author

fitzgen commented Oct 27, 2016

Are running the tests with DYLD_LIBRARY_PATH and LIBCLANG_PATH set?

@igilham
Copy link

igilham commented Oct 27, 2016

I can check that tomorrow. I left that machine at the office.

@igilham
Copy link

igilham commented Oct 27, 2016

Travis seems to like it. I'll see if I can figure out the test environment when the opportunity arises.

bors-servo pushed a commit that referenced this issue Oct 27, 2016
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.
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

No branches or pull requests

3 participants