-
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
Missed niche optimization (Box<impl Sized> & Box<impl Unsized>) #66029
Comments
I think this is a special case of #46213. |
Maybe I'm misunderstanding what you're trying to demonstrate here, but the type:
doesn't lead to Changing that to, say:
is a better example, as the vtable should never be null.
|
@petertodd that one niche is enough. |
@CAD97 Thanks! I see what you mean now. |
This niche is now used and the playground prints |
playground
Specifically, the tagged union of
ptr::NonNull<{Sized type}>
andptr::NonNull<{!Sized type}>
can niche together to be the size ofptr::NonNull<{!Sized type}>
(for unsized types with non-zero sized metadata) by storing the discriminant for the sized pointer in the 0 niche of the non-null pointer to the unsized type (and the pointer to the sized type in the pointer metadata of the unsized type).The text was updated successfully, but these errors were encountered: