Skip to content

Exhaustiveness of pattern matching for numerical values. #32381

Closed
@tmielcza

Description

@tmielcza

When I try to compile this code:

fn main() {
    let t: u8 = 3;
    match t {
        0x00...0x100 => (),
    }
}

I got the following error:

src/main.rs:36:5: 38:6 error: non-exhaustive patterns: `_` not covered [E0004]
src/main.rs:36     match t {
src/main.rs:37         0x00...0x100 => (),
src/main.rs:38     }

while 0x00 to 0x100 covers all possible values for a u8.
Why is that?

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions