It is correct to lower ! to _.

This commit is contained in:
Nadrieril 2024-01-31 01:23:35 +01:00
parent 5ad7454f75
commit ee2cddd8f2

View File

@ -680,8 +680,9 @@ pub fn lower_pat(&self, pat: &'p Pat<'tcx>) -> DeconstructedPat<'p, 'tcx> {
cx.pattern_arena.alloc_from_iter(pats.into_iter().map(|p| self.lower_pat(p))) cx.pattern_arena.alloc_from_iter(pats.into_iter().map(|p| self.lower_pat(p)))
} }
PatKind::Never => { PatKind::Never => {
// FIXME(never_patterns): handle `!` in exhaustiveness. This is a sane default // A never pattern matches all the values of its type (namely none). Moreover it
// in the meantime. // must be compatible with other constructors, since we can use `!` on a type like
// `Result<!, !>` which has other constructors. Hence we lower it as a wildcard.
ctor = Wildcard; ctor = Wildcard;
fields = &[]; fields = &[];
} }