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

Tracking Issue for comparing TypeId in const items #101871

Open
1 of 4 tasks
raldone01 opened this issue Sep 15, 2022 · 0 comments
Open
1 of 4 tasks

Tracking Issue for comparing TypeId in const items #101871

raldone01 opened this issue Sep 15, 2022 · 0 comments
Labels
C-tracking-issue Category: A tracking issue for an RFC or an unstable feature. T-lang Relevant to the language team, which will review and decide on the PR/issue. T-libs-api Relevant to the library API team, which will review and decide on the PR/issue.

Comments

@raldone01
Copy link
Contributor

raldone01 commented Sep 15, 2022

Feature gate: #![feature(const_cmp_type_id)]

This is a tracking issue for comparing TypeId in const items.

Public API

impl const PartialEq for TypeId {}
impl const PartialOrd for TypeId {}
impl const Ord for TypeId {}

Steps / History

Unresolved Questions

  • Making these const precludes some possible implementations, such as the one where TypeId includes a pointer to a static as proposed in TypeId: use a (v0) mangled type to remain sound in the face of hash collisions. #95845. This const-ness should not be stabilized without an explicit decision that we never want such an implementation.

    raldone01: I don't think adding a 'static pointer would be a problem as the contents of the pointer would be compared and not the pointer addresses.

Footnotes

  1. https://std-dev-guide.rust-lang.org/feature-lifecycle/stabilization.html

@raldone01 raldone01 added C-tracking-issue Category: A tracking issue for an RFC or an unstable feature. T-libs-api Relevant to the library API team, which will review and decide on the PR/issue. labels Sep 15, 2022
@scottmcm scottmcm added the T-lang Relevant to the language team, which will review and decide on the PR/issue. label Sep 28, 2022
Dylan-DPC added a commit to Dylan-DPC/rust that referenced this issue Jan 17, 2023
…=scottmcm

Constify `TypeId` ordering impls

Tracking issue: rust-lang#101871

Adding const ordering to `TypeId` allows rtti crates to optimize some casting scenarios (without transmuting to `u64`). This would also prevent these crates from breaking if the underlying type is changed from `u64` to something different.

Feature gate: `#![feature(const_cmp_type_id)]`
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
C-tracking-issue Category: A tracking issue for an RFC or an unstable feature. T-lang Relevant to the language team, which will review and decide on the PR/issue. T-libs-api Relevant to the library API team, which will review and decide on the PR/issue.
Projects
None yet
Development

No branches or pull requests

2 participants