6

Improve and fix diagnostics of exhaustiveness checking

 3 years ago
source link: https://github.com/rust-lang/rust/pull/80104
Go to the source link to view the article. You can view the picture content, updated content and better typesetting reading experience. If the link is broken, please click the button below to view the snapshot at that time.

Contributor

Nadrieril commented 13 days ago

edited

Primarily, this fixes #56379. This also fixes incorrect interactions between or-patterns and slice patterns that I discovered while working on #56379. Those two examples show the incorrect diagnostics:

match &[][..] {
    [true] => {}
    [true // detected as unreachable but that's not true
        | false, ..] => {}
    _ => {}
}
match (true, None) {
    (true, Some(_)) => {}
    (false, Some(true)) => {}
    (true | false, None | Some(true // should be detected as unreachable
                               | false)) => {}
}

I did not measure any perf impact. However, I suspect that 616ba9f should have a negative impact on large or-patterns. I'll see what the perf run says; I have optimization ideas up my sleeve if needed.

EDIT: I initially had a noticeable perf impact that I thought unavoidable. I then proceeded to avoid it x)

r? @varkor
@rustbot label +A-exhaustiveness-checking


About Joyk


Aggregate valuable and interesting links.
Joyk means Joy of geeK