Add never_patterns feature gate

This commit is contained in:
Nadrieril 2023-11-22 02:30:43 +01:00
parent bf86fe130c
commit 02e50f03bf
6 changed files with 8 additions and 2 deletions

View file

@ -1017,6 +1017,7 @@ impl<'a, 'tcx> SpanlessHash<'a, 'tcx> {
}
e.hash(&mut self.s);
},
PatKind::Never => {},
PatKind::Wild => {},
}
}

View file

@ -1707,6 +1707,7 @@ pub fn is_refutable(cx: &LateContext<'_>, pat: &Pat<'_>) -> bool {
match pat.kind {
PatKind::Wild => false,
PatKind::Never => false, // If `!` typechecked then the type is empty, so not refutable.
PatKind::Binding(_, _, _, pat) => pat.map_or(false, |pat| is_refutable(cx, pat)),
PatKind::Box(pat) | PatKind::Ref(pat, _) => is_refutable(cx, pat),
PatKind::Lit(..) | PatKind::Range(..) => true,