Skip to content

Pad size of TypeId and remove structural equality#99189

Closed
carbotaniuman wants to merge 9 commits intorust-lang:masterfrom
carbotaniuman:typeid-changes
Closed

Pad size of TypeId and remove structural equality#99189
carbotaniuman wants to merge 9 commits intorust-lang:masterfrom
carbotaniuman:typeid-changes

Conversation

@carbotaniuman
Copy link
Contributor

This implements @eddyb's suggestions from #95845

Acouple smaller things could also be done (not sure if I'll be able to help with either):

  • manual PartialEq impl for TypeId (i.e. turning off "structural match")

    • this would disallow match-ing on TypeIds (forcing the use of == instead), as to not box ourselves into a corner if address equality is ever needed in the future
  • increasing TypeId's size (and cratering that change)

    • should help with breaking misuses (just like comments on this PR describe)

    • it doesn't have to be actual new data, could just be a dead field

      • this is library-only, e.g. TypeId(type_hash::<T>()) -> TypeId(type_hash::<T>(), 0)

Given that the lang-team has already committed to a full length cryptographic hash, increasing the size of TypeId in preparation for a future change to a cryptographic hash should be a simple stepping stone. This also removes structural equality from TypeId for more futureproofing.

Loading
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

S-waiting-on-review Status: Awaiting review from the assignee but also interested parties. T-libs Relevant to the library team, which will review and decide on the PR/issue.

Projects

None yet

Development

Successfully merging this pull request may close these issues.