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

Exhaustiveness of pattern matching for numerical values. #32381

Closed
tmielcza opened this issue Mar 20, 2016 · 2 comments
Closed

Exhaustiveness of pattern matching for numerical values. #32381

tmielcza opened this issue Mar 20, 2016 · 2 comments

Comments

@tmielcza
Copy link

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?

@jonas-schievink
Copy link
Contributor

This is just not implemented. Last time this was brought up, it was closed in favor of an RFC.

(0x100 is too large for u8 by the way - you want 0xff since ... is inclusive)

@steveklabnik
Copy link
Member

Yes, this is a duplicate of #12483, and would require an RFC.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

3 participants