Skip to content

clang::Cursor::specialized should return an Option<clang::Cursor> #122

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 24, 2016 · 5 comments
Closed

clang::Cursor::specialized should return an Option<clang::Cursor> #122

fitzgen opened this issue Oct 24, 2016 · 5 comments

Comments

@fitzgen
Copy link
Member

fitzgen commented Oct 24, 2016

Right now, clang::Cursor::specialized returns a clang::Cursor regardless if that resulting cursor is_valid() or not. This is a footgun for callers, which have to remember to check resulting_cursor.is_valid(). Instead, specialized should check for them and return None if it is not a valid cursor, and Some if it is.

I can mentor someone who would like to pick up this bug.

@highfive
Copy link

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

@glasserc
Copy link
Contributor

glasserc commented Nov 2, 2016

This looks fun and I will give it a shot today!

@fitzgen
Copy link
Member Author

fitzgen commented Nov 2, 2016

Great! Don't hesitate to reach out if you run into any roadblocks :)

@glasserc
Copy link
Contributor

glasserc commented Nov 2, 2016

This might be a silly question, but why is it possible for a cursor to be invalid? Shouldn't the presence of a Cursor mean that it is valid and that you can use it? Shouldn't invalid cursors themselves be represented using None or something? I guess that's a larger issue than just changing this one method though..

glasserc added a commit to glasserc/rust-bindgen that referenced this issue Nov 2, 2016
glasserc added a commit to glasserc/rust-bindgen that referenced this issue Nov 2, 2016
@fitzgen
Copy link
Member Author

fitzgen commented Nov 2, 2016

Agreed! But we're using FFI to Clang and we don't get to decide how Clang represents its data structures :)

We do want to make it so that our wrapper Cursor type never contains a null or invalid Clang cursor, but this is a bit more work (or at least requires some more investigation and experimentation). See #119.

Fixing issues like this one will certainly help us get there, though!

bors-servo pushed a commit that referenced this issue Nov 3, 2016
Make clang::Cursor::specialized return an Option

Fixes #122.

pair=@Natim
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