Skip to content

NonNull<T> doesn't guarantee ABI compatibility with *mut T #157741

Description

@jacobsa

View all comments

std::num::NonZero<T> guarantees that it is ABI compatible with T for all non-zero values. As far as I can tell:

  • There is no such guarantee for std::ptr::NonNull.

  • …but it actually does hold in practice, given the repr(transparent) implementation.

Is the fact that this isn't guaranteed just an oversight, or is it on purpose?

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-layoutArea: Memory layout of typesA-raw-pointersArea: raw pointers, MaybeUninit, NonNullC-bugCategory: This is a bug.T-libsRelevant to the library team, which will review and decide on the PR/issue.T-opsemRelevant to the opsem team

    Type

    No type

    Projects

    No projects

      Milestone

      No milestone

      Relationships

      None yet

      Development

      No branches or pull requests

      Issue actions