Skip to content

Clarify that Rust std library unsafe tricks can't always be used by others #58582

Open
@upsuper

Description

@upsuper

The union RFC says:

In addition, since a union declared without #[repr(C)] uses an unspecified binary layout, code reading fields of such a union or pattern-matching such a union must not read from a field other than the one written to.

However, there are several cases which explicitly read from a field different from the one written to, for example, str.as_bytes() which was introduced in #50863 to make many of the stuff const.

Metadata

Metadata

Assignees

No one assigned

    Labels

    A-docsArea: Documentation for any part of the project, including the compiler, standard library, and toolsC-enhancementCategory: An issue proposing an enhancement or a PR with one.T-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