-
Notifications
You must be signed in to change notification settings - Fork 707
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
Strongly type ids #1050
Strongly type ids #1050
Conversation
☔ The latest upstream changes (presumably #1049) made this pull request unmergeable. Please resolve the merge conflicts. |
This commit also makes `BindgenContext::resolve_type` take a `TypeId`, and adds unchecked conversions everywhere that we call it. Next, I'm going to go through the code base, replacing these unchecked conversions with checked ones, and tightening up types as I go.
None of the callers were passing template parameters.
…ypeId` This commit makes certain `TypeKind`s that can only reference other types use `TypeId` instead of `ItemId`.
The definition of a template is always a type, so it should be a TypeId rather than an ItemId. Template arguments, on the other hand are not guaranteed to be types. They can be constant values, for example.
And also allow ID comparison across ID types, as this makes implementing the above much easier.
e7d8f94
to
3495d03
Compare
r? @pepyakin |
src/ir/context.rs
Outdated
@@ -1066,15 +1253,15 @@ impl BindgenContext { | |||
} | |||
|
|||
/// Look up whether the item with `id` has vtable or not. | |||
pub fn lookup_item_id_has_vtable(&self, id: &ItemId) -> bool { | |||
pub fn lookup_item_id_has_vtable<Id: Into<ItemId>>(&self, id: Id) -> bool { |
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.
I suppose has_vtable
is defined only for types and calling it on a not type is bit smelly. Would it be hard to change this fn to only accept TypeId
?
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.
Good call -- I'll give it a try.
Its not just item ids now, and that name was pretty long...
@pepyakin OK, I made |
Looks great! @bors-servo r+ |
@pepyakin: 🔑 Insufficient privileges: Not in reviewers |
@bors-servo r=pepyakin Hmm doesn't seem to be deployed yet... |
📌 Commit 5f3bf1f has been approved by |
Strongly type ids * [X] `TypeId` * [X] `ModuleId` * [x] `VarId` * [x] `FunctionId`
💔 Test failed - status-travis |
☀️ Test successful - status-travis |
TypeId
ModuleId
VarId
FunctionId