Skip to content
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

Merged
merged 25 commits into from
Oct 2, 2017
Merged

Strongly type ids #1050

merged 25 commits into from
Oct 2, 2017

Conversation

fitzgen
Copy link
Member

@fitzgen fitzgen commented Sep 30, 2017

  • TypeId
  • ModuleId
  • VarId
  • FunctionId

@bors-servo
Copy link

☔ The latest upstream changes (presumably #1049) made this pull request unmergeable. Please resolve the merge conflicts.

fitzgen added 22 commits October 2, 2017 11:32
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.
@fitzgen fitzgen force-pushed the strongly-type-ids branch from e7d8f94 to 3495d03 Compare October 2, 2017 19:23
@fitzgen
Copy link
Member Author

fitzgen commented Oct 2, 2017

r? @pepyakin

@fitzgen fitzgen changed the title [WIP] Strongly type ids Strongly type ids Oct 2, 2017
@@ -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 {
Copy link
Contributor

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?

Copy link
Member Author

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.

@fitzgen
Copy link
Member Author

fitzgen commented Oct 2, 2017

@pepyakin OK, I made is_unsized, has_vtable, and has_destructor methods all take TypeId.

@pepyakin
Copy link
Contributor

pepyakin commented Oct 2, 2017

Looks great!

@bors-servo r+

@bors-servo
Copy link

@pepyakin: 🔑 Insufficient privileges: Not in reviewers

@fitzgen
Copy link
Member Author

fitzgen commented Oct 2, 2017

@bors-servo r=pepyakin

Hmm doesn't seem to be deployed yet...

@bors-servo
Copy link

📌 Commit 5f3bf1f has been approved by pepyakin

@bors-servo
Copy link

⌛ Testing commit 5f3bf1f with merge c66598d...

bors-servo pushed a commit that referenced this pull request Oct 2, 2017
Strongly type ids

* [X] `TypeId`
* [X] `ModuleId`
* [x] `VarId`
* [x] `FunctionId`
@bors-servo
Copy link

💔 Test failed - status-travis

@bors-servo
Copy link

☀️ Test successful - status-travis
Approved by: pepyakin
Pushing c66598d to master...

@bors-servo bors-servo merged commit 5f3bf1f into rust-lang:master Oct 2, 2017
@fitzgen fitzgen deleted the strongly-type-ids branch October 2, 2017 21:13
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

Successfully merging this pull request may close these issues.

4 participants