Compiling Rust is NP-hard
The actual code that handles exhaustiveness checks has extensive explanations on how it works and what it was inspired by.<p><a href="https://github.com/rust-lang/rust/blob/master/compiler/rustc_mir_build/src/thir/pattern/usefulness.rs" rel="nofollow">https://github.com/rust-lang/rust/blob/master/compiler/rustc...</a>