Skip to content

Commit ee2cddd

Browse files
committed
It is correct to lower ! to _.
1 parent 5ad7454 commit ee2cddd

File tree

1 file changed

+3
-2
lines changed
  • compiler/rustc_pattern_analysis/src

1 file changed

+3
-2
lines changed

compiler/rustc_pattern_analysis/src/rustc.rs

+3-2
Original file line numberDiff line numberDiff line change
@@ -680,8 +680,9 @@ impl<'p, 'tcx> RustcMatchCheckCtxt<'p, 'tcx> {
680680
cx.pattern_arena.alloc_from_iter(pats.into_iter().map(|p| self.lower_pat(p)))
681681
}
682682
PatKind::Never => {
683-
// FIXME(never_patterns): handle `!` in exhaustiveness. This is a sane default
684-
// in the meantime.
683+
// A never pattern matches all the values of its type (namely none). Moreover it
684+
// must be compatible with other constructors, since we can use `!` on a type like
685+
// `Result<!, !>` which has other constructors. Hence we lower it as a wildcard.
685686
ctor = Wildcard;
686687
fields = &[];
687688
}

0 commit comments

Comments
 (0)