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

Invalid non-exhaustive pattern error on scalar values #16199

Closed
lifthrasiir opened this issue Aug 2, 2014 · 2 comments
Closed

Invalid non-exhaustive pattern error on scalar values #16199

lifthrasiir opened this issue Aug 2, 2014 · 2 comments

Comments

@lifthrasiir
Copy link
Contributor

fn foo(c: char) {
    match c {
        '\u0000'..'\ud7ff' | '\ue000'..'\uffff' => println!("BMP"),
        '\U00010000'..'\U0010ffff' => println!("non-BMP"),
    }
}

...results in:

<anon>:2:5: 5:6 error: non-exhaustive patterns: `_` not covered [E0004]
<anon>:2     match c {
<anon>:3         '\u0000'..'\ud7ff' | '\ue000'..'\uffff' => println!("BMP"),
<anon>:4         '\U00010000'..'\U0010ffff' => println!("non-BMP"),
<anon>:5     }

These patterns clearly encompass the entire domain of char but the exhaustiveness checker doesn't know that. In fact, this occurs for every scalar value:

fn foo(v: u8) {
    match v {
        -128 .. 7 => println!("<= 7"),
        8 .. 127 => println!("> 7"),
    }
}

...but char is the prominent example of this issue.

@ghost
Copy link

ghost commented Aug 2, 2014

Dup of #12483.

@alexcrichton
Copy link
Member

Looks to be so!

bors added a commit to rust-lang-ci/rust that referenced this issue Jan 8, 2024
… r=Veykril

fix: `extract_struct_from_enum_variant` assist should resolve Self generic arg

close rust-lang/rust-analyzer#16197
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

2 participants