Skip to content

Make sure to be sound in the face of coinductive unsafe trait impls #3380

Description

@joshlf

Rust currently has a soundness hole where coinductive unsafe trait impls are unsound, e.g.:

struct NotSend(Rc<()>);

unsafe impl Send for NotSend
where
    NotSend: Send
{}

Note that this only holds for auto traits. In particular, recursive impls for non-auto traits are considered unsatisfied:

error[E0275]: overflow evaluating the requirement `NotSend: Foo`
  --> src/lib.rs:11:5
   |
11 |     NotSend: Foo
   |     ^^^^^^^^^^^^
   |
   = help: see issue #48214

We need to figure out whether we're okay saying "we're unsound because Rust itself is unsound" or whether we want to try to forbid these somehow.

cc @lcnr

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