Skip to content

uninhabited enum variants still block auto trait implementation #101083

Open
@soqb

Description

@soqb
#![feature(never_type)]

use std::rc::Rc;

// struct that is neither send nor constructable
struct NotSend {
    no_construct: !,
    no_send: Rc<()>,
}

// struct that is both send and constructable
struct IsSend;

// is not send even though the non-send variant can never be constructed
enum AlsoNotSend {
    CanBeConstructed(IsSend), // is send
    CannotBeConstructed(NotSend), // is not send
}

fn takes_send<T: Send>() {}

fn main() {
    takes_send::<IsSend>();
    // ^^ compiles fine!
    
    // takes_send::<AlsoNotSend>();
    // ^^ does not compile!
    
    // takes_send::<Result<u8, (!, Rc<()>)>>();
    // ^^ also affects this case!
}

another example can be found here

Metadata

Metadata

Assignees

No one assigned

    Labels

    F-never_type`#![feature(never_type)]`T-langRelevant to the language team, which will review and decide on the PR/issue.

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions