Skip to content

Add safe standard DeviceCopy parity impls #201

Closed

Description

@niklebedenko

Problem

cuda_core::DeviceCopy is missing several standard-library impls that are safe under the trait's byte-copy and zero-initialization contract. In particular, bool, char, and transparent wrapper/container types such as PhantomData<T>, MaybeUninit<T>, and Wrapping<T> cannot currently be used in otherwise transfer-safe device buffer payloads.

Why this matters

DeviceCopy is the core marker for values that may cross the host/device boundary. Missing impls force users either to avoid ordinary Rust field types or to add local unsafe wrapper impls even when the layout rule is already known and can be encoded once in cuda-core.

The all-zero validity requirement still matters: types such as bare NonZero*, blanket Option<T>, and blanket Result<T, E> should not be accepted unless their zero bit pattern is known to be valid.

Expected behavior

DeviceCopy should cover standard types whose copy and zero-initialization semantics are valid and layout-stable enough for the trait:

  • bool and char;
  • PhantomData<T>;
  • MaybeUninit<T> when T: DeviceCopy;
  • Wrapping<T> when T: DeviceCopy.

Acceptance criteria

  • A compile regression using these standard types fails on upstream/main without the impls.
  • The same regression passes on the patched branch.
  • Device and pinned-host zeroed-buffer tests prove the newly accepted scalar values work with the existing all-zero initialization API.
  • The patch does not add unsafe blanket impls for NonZero*, Option<T>, or Result<T, E>.

Activity

  1. niklebedenko commented on Jun 16, 2026

    @niklebedenko
    ContributorAuthor

    N.b. bool and char haven't been added in #202, everything else I mentioned has.

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

    No labels
    No labels

    Type

    No type

    Projects

    No projects

      Milestone

      No milestone

      Relationships

      None yet

      Development

      No branches or pull requests

      Issue actions