-
Notifications
You must be signed in to change notification settings - Fork 48
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
NonNull
vs *const
in Repr
#356
Comments
IMO it's probably because the inline repr, where the first character can be |
Sorry if my question was confused. I understand that My question was really: Does it matter that |
Hmmm yeah it gets ignored currently, but I guess maybe in the future it can be changed to take advantage of that? For example, we can represent empty inline string using |
Nice idea. That would deal with the empty string case. But there is still one weird case where 0 is valid bit pattern for all of 1st 8 bytes: So question is then: Should And is there a reason why |
Maybe we should treat If a string only consists of null bytes , then treat it as empty string? |
Bingo!
No particular reason,
AFAIU it's okay that they don't match, and |
Thanks for coming back. If I may ask one more probably stupid question: Why "should" their pointers be |
This reminds me of a problem: with arm CHERI, size of pointer is 128 bits instead of 64 bits, containing an extra tag for the heap allocation. It looks like we might have to update this crate to support arm CHERI @ParkMyCar |
I've opened a separate issue #378 for that point NobodyXu (just because if possible I'd be really interested in answer to my question above, and didn't want conversation here to get sidetracked). |
This is a question more than a bug report, but just asking in case it reveals something more useful...
Repr
's 1st field is a*const ()
.HeapBuffer
's 1st field is aptr::NonNull<u8>
.StaticStr
's 1st field is aptr::NonNull<u8>
.HeapBuffer
andStaticStr
are both transmuted toRepr
.Is there a benefit to
HeapBuffer
andStaticStr
usingNonNull<u8>
rather than*const
? Does it matter that a value with a niche is transmuted to one without?Second smaller question: Why
*const ()
inRepr
instead of*const u8
? Only place which accesses this field seems to beas_slice
, where it's immediately cast to*const u8
. Probably it makes no difference to codegen, but I'm wondering if there's a subtlety I'm missing.The text was updated successfully, but these errors were encountered: