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

'Type layout' and 'Dynamically Sized Types' pages disagree on whether the size of a pointer to a DST is defined #1303

Open
Liamolucko opened this issue Nov 17, 2022 · 3 comments

Comments

@Liamolucko
Copy link

The 'Dynamically Sized Types' page pretty clearly states that the size of a pointer to a DST is twice the size of a regular pointer:

  • Pointer types to DSTs are sized but have twice the size of pointers to sized types

But, the 'Type layout' page gives this much less concrete answer:

  • Pointers to unsized types are sized. The size and alignment is guaranteed to be at least equal to the size and alignment of a pointer.

And, in a note, it says the same thing as the DST page, but says that it shouldn't be relied upon:

Note: Though you should not rely on this, all pointers to DSTs are currently twice the size of the size of usize and have the same alignment.

The two pages should be consistent. Assuming that the DST page is correct, the type layout page should also concretely say that pointers to unsized types are twice the size of regular pointers, and the note should be removed.

@bjorn3
Copy link
Member

bjorn3 commented Nov 17, 2022

You can have pointers to DST's that are the same size as pointers to regular types using the unstable extern { type Foo; }. In the future we might also get them larger than twice the size of regular pointers if we get custom DST's.

@Liamolucko
Copy link
Author

Okay - so the DST page is wrong?

@bjorn3
Copy link
Member

bjorn3 commented Nov 17, 2022

It is outdated. extern { type Foo; } probably didn't exist yet when that page was written.

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

No branches or pull requests

2 participants