Closed
Description
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.
Metadata
Metadata
Assignees
Labels
No labels