Skip to content

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

Closed
@Nadrieril

Description

@Nadrieril

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).

Metadata

Metadata

Assignees

Labels

C-bugCategory: This is a bug.F-non_exhaustive`#![feature(non_exhaustive)]`T-compilerRelevant to the compiler team, which will review and decide on the PR/issue.requires-nightlyThis issue requires a nightly compiler in some way.

Type

No type

Projects

No projects

Milestone

No milestone

Relationships

None yet

Development

No branches or pull requests

Issue actions