-
Notifications
You must be signed in to change notification settings - Fork 747
Make clang::Cursor::fallible_semantic_parent make ffi call #172
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
Make clang::Cursor::fallible_semantic_parent make ffi call #172
Conversation
r? @fitzgen |
This is conceptually ok, but breaks the tests very badly. Most of the callees handled the invalid cursor themselves, so they need to be fixed also. |
Changes themselves look good. Did you re-run the tests? As @emilio pointed out, they're failing now. I would Does that make sense? |
Yes, thanks for the feedback! Did not think this was going to break things so I did not run the tests, oops. |
☔ The latest upstream changes (presumably #183) made this pull request unmergeable. Please resolve the merge conflicts. |
fe01673
to
bfc0290
Compare
// Yes, the second can happen with, e.g., macro definitions. | ||
semantic_parent == tu || semantic_parent == tu.semantic_parent() | ||
// Yes, this can happen with, e.g., macro definitions. | ||
semantic_parent == tu.fallible_semantic_parent() |
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.
At this point, semantic_parent.unwrap()
is now None
. Therefore true
can only be returned if tu
is None
or tu.fallible_semantic_parent()
is None
. tu
will never be None
because it is a Cursor
type, so the first check is now unnecessary.
I had to make changes to Thank you to @fitzgen for helping me figure out what's going on! |
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.
LGTM! Thanks @malisas!
r? @emilio -- care to rubber stamp this? |
Oh, sure, sorry I missed this one. @bors-servo r=fitzgen,emilio |
📌 Commit bfc0290 has been approved by |
…milio Make clang::Cursor::fallible_semantic_parent make ffi call This PR fixes #120 . `clang::Cursor::semantic_parent` now just calls `clang::Cursor::fallible_semantic_parent`, and the ffi call has been moved into `fallible_semantic_parent`. This change broke a number of tests which call `is_toplevel()` (which itself calls `semantic_parent()`): > panicked at called Option::unwrap() on a None value So I re-wrote `is_toplevel()` to call `fallible_semantic_parent()`, which returns an `Option<Cursor>` type instead.
☀️ Test successful - status-travis |
This PR fixes #120 .
clang::Cursor::semantic_parent
now just callsclang::Cursor::fallible_semantic_parent
, and the ffi call has been moved intofallible_semantic_parent
.This change broke a number of tests which call
is_toplevel()
(which itself callssemantic_parent()
):So I re-wrote
is_toplevel()
to callfallible_semantic_parent()
, which returns anOption<Cursor>
type instead.