Skip to content

Can references inside an enum transiently set an invalid enum discriminant? #621

Description

@nia-e

Per #414 (comment), opsem consensus appeared to be that a &mut T can write an invalid value of T "temporarily", so long as it's restored to a valid form before returning into safe code. Does this also mean that, for a T with niches, it is valid to overwrite the discriminant of a wrapping enum (e.g. could a &mut NonNull<T> transiently write 0 or uninit even if the said NonNull was part of an Option<NonNull<T>>)?

Relevant to rust-lang/rust#161452

Metadata

Metadata

Assignees

No one assigned

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions