Skip to content

uninhabited enum variants still block auto trait implementation #101083

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Open
soqb opened this issue Aug 27, 2022 · 1 comment
Open

uninhabited enum variants still block auto trait implementation #101083

soqb opened this issue Aug 27, 2022 · 1 comment
Labels
F-never_type `#![feature(never_type)]` T-lang Relevant to the language team, which will review and decide on the PR/issue.

Comments

@soqb
Copy link
Contributor

soqb commented Aug 27, 2022

#![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

@soqb
Copy link
Contributor Author

soqb commented Aug 27, 2022

might be related to #38885

@soqb soqb changed the title enum variants that cannot be constructed still block auto trait implementation uninhabited enum variants still block auto trait implementation Nov 10, 2022
@jyn514 jyn514 added F-never_type `#![feature(never_type)]` T-lang Relevant to the language team, which will review and decide on the PR/issue. labels Apr 12, 2023
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
F-never_type `#![feature(never_type)]` T-lang Relevant to the language team, which will review and decide on the PR/issue.
Projects
None yet
Development

No branches or pull requests

2 participants