Uh oh!
There was an error while loading. Please reload this page.
Introduce UnpackedKind - #48452
Conversation
This adds an `UnpackedKind` type as a typesafe counterpart to `Kind`. This should make future changes to kinds (such as const generics!) more resilient, as the type-checker should catch more potential issues.
| TYPE_TAG => unsafe { | ||
| UnpackedKind::Type(&*((ptr & !TAG_MASK) as *const _)) | ||
| }, | ||
| _ => bug!("packed kind has invalid tag") |
There was a problem hiding this comment.
cc @nikomatsakis Should this be bug!? That seems expensive. intrinsics::unreachable() should be fine since Kind can't be safely created with a different tag, and would avoid unnecessary cases in matches.
There was a problem hiding this comment.
I agree that unreachable! in this case seems ok, since we're meddling in unsafe code, and this is inside the abstraction barrier. Plus this is "inner loop" code.
eddyb
commented
Feb 23, 2018
r=me when the fallback case in |
| Ok(Kind::from(relation.relate_with_variance(variance, &a_r, &b_r)?)) | ||
| } else { | ||
| bug!() | ||
| match (a.unpack(), b.unpack()) { |
There was a problem hiding this comment.
nice, I've been wanting this to be done forever =)
| TYPE_TAG => unsafe { | ||
| UnpackedKind::Type(&*((ptr & !TAG_MASK) as *const _)) | ||
| }, | ||
| _ => bug!("packed kind has invalid tag") |
There was a problem hiding this comment.
I agree that unreachable! in this case seems ok, since we're meddling in unsafe code, and this is inside the abstraction barrier. Plus this is "inner loop" code.
eddyb
commented
Feb 23, 2018
@bors r+ |
bors
commented
Feb 23, 2018
📌 Commit f2b9686 has been approved by |
bors
commented
Feb 23, 2018
🌲 The tree is currently closed for pull requests below priority 99, this pull request will be tested once the tree is reopened |
Introduce UnpackedKind This adds an `UnpackedKind` type as a typesafe counterpart to `Kind`. This should make future changes to kinds (such as const generics!) more resilient, as the type-checker will be able to catch more potential issues. r? @eddyb cc @yodaldevoid
This adds an
UnpackedKindtype as a typesafe counterpart toKind. This should make future changes to kinds (such as const generics!) more resilient, as the type-checker will be able to catch more potential issues.r? @eddyb
cc @yodaldevoid