-
-
Notifications
You must be signed in to change notification settings - Fork 17.5k
size_of_val_raw is not a generalization of size_of_val #163246
Copy link
Copy link
Closed
Labels
A-docsArea: Documentation for any part of the project, including the compiler, standard library, and toolsArea: Documentation for any part of the project, including the compiler, standard library, and toolsT-langRelevant to the language teamRelevant to the language teamT-libsRelevant to the library team, which will review and decide on the PR/issue.Relevant to the library team, which will review and decide on the PR/issue.
Description
Activity
Metadata
Metadata
Assignees
Labels
A-docsArea: Documentation for any part of the project, including the compiler, standard library, and toolsArea: Documentation for any part of the project, including the compiler, standard library, and toolsT-langRelevant to the language teamRelevant to the language teamT-libsRelevant to the library team, which will review and decide on the PR/issue.Relevant to the library team, which will review and decide on the PR/issue.
Location (URL)
https://doc.rust-lang.org/std/mem/fn.size_of_val_raw.html#safety
Summary
The safety requirements of
size_of_val_rawstate that conservatively, you are not allowed to call the function on anything other thanT: Sized,[T],dyn TraitandExternType(and types with unsized tail of these kinds).But this means that even for pointers created from references, downstream code is not allowed to call the function in contexts where the pointee type is a generic
T: ?Sized; it has to assume that there may be other kinds of types that don't fall into one of these cases.This seems like an oversight.
@rustbot label T-libs T-lang