Skip to content

Atomic<ptr> is no longer possible #49

@Tazdevil971

Description

@Tazdevil971

As per title, since the addition of T: NoUninit pointers are no longer allowed inside an Atomic<...>.

This is per definition of NoUninit, which I quote:

It is disallowed for types to contain pointer types, Cell, UnsafeCell, atomics, and any other forms of interior mutability.

It is unclear to me why pointer types are disallowed inside a NoUninit as they do not provide interior mutability directly. Anyway this is clearly limiting, as pointer inside atomics are allowed (proved by the existence of AtomicPtr).

My specific use case is something akin to this:

struct BarPtr(NonNull<Bar>);

// ...

struct Foo {
  // ...
  bar: Atomic<Option<BarPtr>>,
  // ...
}

I think that a way to fix this is to have this crate contain its own trait asserting that a type "is safe inside an Atomic<...>", implement it for all T: NoUninit but still allowing for unsafe manual implementation. This could also be used to make the dependency bytemuck optional.

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions