-
Notifications
You must be signed in to change notification settings - Fork 12.8k
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
Pad size of TypeId and remove structural equality #99189
Changes from 4 commits
642b8e1
61e9395
0bb7737
7985d93
b35362c
34b2cce
e531a9a
ee6d19b
53dcb86
File filter
Filter by extension
Conversations
Jump to
Diff view
Diff view
There are no files selected for viewing
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -5,20 +5,9 @@ | |
// will be properly rejected. This test will ensure that monomorphic use of these | ||
// would not be wrongly rejected in patterns. | ||
|
||
#![feature(const_type_id)] | ||
#![feature(const_type_name)] | ||
|
||
use std::any::{self, TypeId}; | ||
|
||
pub struct GetTypeId<T>(T); | ||
|
||
impl<T: 'static> GetTypeId<T> { | ||
pub const VALUE: TypeId = TypeId::of::<T>(); | ||
} | ||
|
||
const fn check_type_id<T: 'static>() -> bool { | ||
matches!(GetTypeId::<T>::VALUE, GetTypeId::<usize>::VALUE) | ||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. I don't think we should lose the ability to compare type ids in CTFE. Comparison is almost the only thing you can do with a type id. It's possible to make There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Note that There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Do you know if we already have a test case that covers that @carbotaniuman? There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Hmm, maybe I'm missing something but it doesn't appear that
As far as I can tell that would still be the case after this PR, except that we'd also lose the ability to compare type ids by matching them. There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Yeah, it looks like I was mistaken here, and I'll likely reopen this PR with more substantial work behind it. |
||
} | ||
use std::any; | ||
|
||
pub struct GetTypeNameLen<T>(T); | ||
|
||
|
@@ -31,6 +20,5 @@ const fn check_type_name_len<T: 'static>() -> bool { | |
} | ||
|
||
fn main() { | ||
assert!(check_type_id::<usize>()); | ||
assert!(check_type_name_len::<usize>()); | ||
} |
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.
This should have some comment why that field added, as it isn't obvious.