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

[pointer][WIP] Transmute #2408

Open
wants to merge 1 commit into
base: Ie66db9044be1dc310a6b7280a73652a357878376
Choose a base branch
from

Conversation

joshlf
Copy link
Member

@joshlf joshlf commented Feb 28, 2025

@joshlf
Copy link
Member Author

joshlf commented Feb 28, 2025

I think we may have to handle UnsafeCell agreement after all. In particular, in order to implement TryFromBytes for atomics, we need to be able to go from e.g. Ptr<AtomicU8> to Ptr<UnsafeCell<u8>> so that we can call <UnsafeCell<u8> as TryFromBytes>::is_bit_valid. This will require care since this is unsound for shared aliasing. We know in practice that we'll always be using exclusive aliasing, but I'm not sure how to express that generically.

@joshlf joshlf force-pushed the Iad14813bc6d933312bc8d7a1ddcf1aafc7126938 branch from 4bd4fd9 to f1b2bec Compare March 2, 2025 23:21
@joshlf joshlf force-pushed the Ie66db9044be1dc310a6b7280a73652a357878376 branch from 03547a1 to 0c59508 Compare March 2, 2025 23:21
@joshlf joshlf force-pushed the Iad14813bc6d933312bc8d7a1ddcf1aafc7126938 branch from f1b2bec to 653cdb9 Compare March 2, 2025 23:46
src/wrappers.rs Outdated
@@ -394,14 +394,14 @@ impl<T: Unaligned> Deref for Unalign<T> {

#[inline(always)]
fn deref(&self) -> &T {
Ptr::from_ref(self).transparent_wrapper_into_inner().bikeshed_recall_aligned().as_ref()
Ptr::from_ref(self).transmute().bikeshed_recall_aligned().as_ref()
Copy link
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Bad news: This fails because it requires T: KnownLayout, which we wanted to avoid. We might be able to work around it with the SizedKnownLayout trick, or we might need to reconsider the T: KnownLayout bound.

@joshlf joshlf force-pushed the Iad14813bc6d933312bc8d7a1ddcf1aafc7126938 branch from 653cdb9 to 3e52166 Compare March 3, 2025 00:02
@joshlf joshlf force-pushed the Ie66db9044be1dc310a6b7280a73652a357878376 branch from 0c59508 to daf3a21 Compare March 3, 2025 00:02
gherrit-pr-id: Iad14813bc6d933312bc8d7a1ddcf1aafc7126938
@joshlf joshlf force-pushed the Iad14813bc6d933312bc8d7a1ddcf1aafc7126938 branch from 3e52166 to 3b22cad Compare March 3, 2025 17:44
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

1 participant