-
Notifications
You must be signed in to change notification settings - Fork 747
Return Option<Type> in clang::Type::ret_type fix #141 #165
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
Conversation
d98f19f
to
a7d5f5d
Compare
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 needs to preserve the old behavior, but looks good otherwise, thanks for doing this!
@@ -186,7 +186,8 @@ impl FunctionSig { | |||
} | |||
} | |||
|
|||
let ret = try!(Item::from_ty(&ty.ret_type(), None, None, ctx)); | |||
let ty_ret_type = ty.ret_type().expect("Expected a valid return type"); |
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 not equivalent to the code that was before. If a type was invalid, before it'll generate a Err(Continue)
, and the try!
macro would make us return it earlier.
With this we're panicking, which isn't desirable.
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.
Thanks you.
I'll update the code.
- Should we add a test for this as well?
- I was under the impression that this code path should not happen (modulo bugs), do you have an idea of what C++ code would trigger it?
Also reduce the scope for unsafe code
a7d5f5d
to
17494de
Compare
Yeah, at that point we indeed should be pretty sure it succeeds. Still feels better to avoid crashing when possible. Thanks for this! @bors-servo r+ |
📌 Commit 17494de has been approved by |
☀️ Test successful - status-travis |
Fixes #141