Skip to content

book: size and align in trait object vtables are used #39191

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

Merged

Conversation

cesarb
Copy link
Contributor

@cesarb cesarb commented Jan 19, 2017

The book currently claims that the size and align fields in the
trait object vtable are not used, but this is false. These two fields
are used by the stable mem::size_of_val and mem::align_of_val
functions.

See the ty::TyDynamic case of the glue::size_and_align_of_dst
function in librustc_trans, which is used to implement both intrinsics
in the unsized case.

r? @steveklabnik

The book currently claims that the `size` and `align` fields in the
trait object vtable are not used, but this is false. These two fields
are used by the stable `mem::size_of_val` and `mem::align_of_val`
functions.

See the `ty::TyDynamic` case of the `glue::size_and_align_of_dst`
function in librustc_trans, which is used to implement both intrinsics
in the unsized case.
@rust-highfive
Copy link
Contributor

Thanks for the pull request, and welcome! The Rust team is excited to review your changes, and you should hear from @steveklabnik (or someone else) soon.

If any changes to this PR are deemed necessary, please add them as extra commits. This ensures that the reviewer can see what has changed since they last reviewed the code. Due to the way GitHub handles out-of-date commits, this should also make it reasonably obvious what issues have or haven't been addressed. Large or tricky changes may require several passes of review and changes.

Please see the contribution instructions for more information.

@KodrAus
Copy link
Contributor

KodrAus commented Jan 19, 2017

Personally, I think it would be better to just remove that bit, and end the sentence at alignment requirements. I'm not sure how useful it is for a reader to know that the size and align fields are used by two specific functions in the standard library.

@steveklabnik
Copy link
Member

I agree with @KodrAus here; would you mind just removing this bit please, @cesarb ? Thanks!

@cesarb
Copy link
Contributor Author

cesarb commented Jan 20, 2017

@steveklabnik done.

@steveklabnik
Copy link
Member

@bors: r+ rollup

thank you!

@bors
Copy link
Collaborator

bors commented Jan 23, 2017

📌 Commit c7b092b has been approved by steveklabnik

steveklabnik added a commit to steveklabnik/rust that referenced this pull request Jan 23, 2017
…ze-and-align, r=steveklabnik

book: size and align in trait object vtables are used

The book currently claims that the `size` and `align` fields in the
trait object vtable are not used, but this is false. These two fields
are used by the stable `mem::size_of_val` and `mem::align_of_val`
functions.

See the `ty::TyDynamic` case of the `glue::size_and_align_of_dst`
function in librustc_trans, which is used to implement both intrinsics
in the unsized case.

r? @steveklabnik
bors added a commit that referenced this pull request Jan 23, 2017
Rollup of 7 pull requests

- Successful merges: #38794, #38956, #38993, #39191, #39200, #39233, #39258
- Failed merges:
@bors bors merged commit c7b092b into rust-lang:master Jan 24, 2017
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.

5 participants