Skip to content
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

#[non_exhaustive] variants are not detected to be redundant #65157

Closed
Nadrieril opened this issue Oct 6, 2019 · 3 comments · Fixed by #65414
Closed

#[non_exhaustive] variants are not detected to be redundant #65157

Nadrieril opened this issue Oct 6, 2019 · 3 comments · Fixed by #65414
Assignees
Labels
C-bug Category: This is a bug. F-non_exhaustive `#![feature(non_exhaustive)]` requires-nightly This issue requires a nightly compiler in some way. T-compiler Relevant to the compiler team, which will review and decide on the PR/issue.

Comments

@Nadrieril
Copy link
Member

Say I have the following enum in crate b:

#![feature(non_exhaustive)]
pub enum Enum {
    Unit,
    #[non_exhaustive] Struct { x: bool }
}

And I match on it in crate a:

#![deny(unreachable_patterns)]
match Enum::Unit {
    Enum::Struct { .. } => {}
    Enum::Struct { .. } => {} // This should error but doesn't
    _ => {}
}

The second branch is not detected to be unreachable. This is on current nightly; playground link (hacky).

@Nadrieril
Copy link
Member Author

The reason for this behaviour is straightforward: this line reports tuple variants with non-exhaustive fields as always useful.
This line was introduced in commit 0d034a2 . I'm not quite sure what the intended semantics are so I wouldn't know how to fix it.

@jonas-schievink jonas-schievink added C-bug Category: This is a bug. requires-nightly This issue requires a nightly compiler in some way. T-compiler Relevant to the compiler team, which will review and decide on the PR/issue. F-non_exhaustive `#![feature(non_exhaustive)]` labels Oct 6, 2019
@davidtwco davidtwco self-assigned this Oct 6, 2019
@Nadrieril
Copy link
Member Author

Please wait for #65160 to be merged before fixing this; I'm dreading having to rebase on top of the fix

@arielb1
Copy link
Contributor

arielb1 commented Oct 14, 2019

cc @davidtwco

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
C-bug Category: This is a bug. F-non_exhaustive `#![feature(non_exhaustive)]` requires-nightly This issue requires a nightly compiler in some way. T-compiler Relevant to the compiler team, which will review and decide on the PR/issue.
Projects
None yet
Development

Successfully merging a pull request may close this issue.

4 participants