Skip to content

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

Merged
merged 1 commit into from
Oct 30, 2016

Conversation

jeanphilippeD
Copy link
Contributor

@jeanphilippeD jeanphilippeD commented Oct 29, 2016

Fixes #141

@highfive
Copy link

warning Warning warning

  • These commits modify unsafe code. Please review it carefully!

Copy link
Contributor

@emilio emilio left a 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");
Copy link
Contributor

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.

Copy link
Contributor Author

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
@emilio
Copy link
Contributor

emilio commented Oct 30, 2016

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+

@bors-servo
Copy link

📌 Commit 17494de has been approved by emilio

@bors-servo
Copy link

⌛ Testing commit 17494de with merge 604965a...

bors-servo pushed a commit that referenced this pull request Oct 30, 2016
Return Option<Type> in clang::Type::ret_type fix #141

Fixes #141
@bors-servo
Copy link

☀️ Test successful - status-travis

@bors-servo bors-servo merged commit 17494de into rust-lang:master Oct 30, 2016
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

4 participants