1
Fork 0

Lower never patterns to Unreachable in mir

This commit is contained in:
Nadrieril 2024-02-20 04:07:50 +01:00
parent 92d65a92e2
commit 57e8aebb6c
14 changed files with 204 additions and 115 deletions

View file

@ -581,8 +581,8 @@ impl<'hir> LoweringContext<'_, 'hir> {
self.dcx().emit_err(NeverPatternWithGuard { span: g.span });
}
// We add a fake `loop {}` arm body so that it typecks to `!`.
// FIXME(never_patterns): Desugar into a call to `unreachable_unchecked`.
// We add a fake `loop {}` arm body so that it typecks to `!`. The mir lowering of never
// patterns ensures this loop is not reachable.
let block = self.arena.alloc(hir::Block {
stmts: &[],
expr: None,