Skip to content

Missing "unreachable pattern" warning on char ranges #79307

Closed
@Nadrieril

Description

@Nadrieril

I tried this code (playground):

match 'a' {
    '\u{0}'..='\u{D7FF}' | '\u{E000}'..='\u{10_FFFF}' => {},
    '\u{D7FF}'..='\u{E000}' => {}, // should be unreachable
}

The first pattern by itself is exhaustive, because it covers all the valid chars. The second pattern looks like it includes more chars than the first, but it doesn't, because those extra chars are all invalid. So the second pattern should be marked unreachable.

This fails on all rust versions on the playground, and I think it's been that way since we implemented exhaustive_integer_patterns. I discovered it while working on the exhaustiveness algorithm.

@rustbot modify labels: +A-exhaustiveness-checking

Metadata

Metadata

Assignees

No one assigned

    Labels

    A-UnicodeArea: UnicodeA-exhaustiveness-checkingRelating to exhaustiveness / usefulness checking of patternsC-bugCategory: This is a bug.T-compilerRelevant to the compiler 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