Skip to content

size_of_val_raw is not a generalization of size_of_val #163246

Description

@maxdexh

Location (URL)

https://doc.rust-lang.org/std/mem/fn.size_of_val_raw.html#safety

Summary

The safety requirements of size_of_val_raw state that conservatively, you are not allowed to call the function on anything other than T: Sized, [T], dyn Trait and ExternType (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

Activity

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Metadata

Metadata

Assignees

No one assigned

    Labels

    A-docsArea: Documentation for any part of the project, including the compiler, standard library, and toolsT-langRelevant to the language teamT-libsRelevant to the library team, which will review and decide on the PR/issue.

    Type

    No type

    Projects

    No projects

      Milestone

      No milestone

      Relationships

      None yet

      Development

      No branches or pull requests

      Issue actions