Lower never patterns to Unreachable in mir
This commit is contained in:
parent
92d65a92e2
commit
57e8aebb6c
14 changed files with 204 additions and 115 deletions
|
@ -682,6 +682,23 @@ impl<'tcx> Pat<'tcx> {
|
|||
true
|
||||
})
|
||||
}
|
||||
|
||||
/// Whether this a never pattern.
|
||||
pub fn is_never_pattern(&self) -> bool {
|
||||
let mut is_never_pattern = false;
|
||||
self.walk(|pat| match &pat.kind {
|
||||
PatKind::Never => {
|
||||
is_never_pattern = true;
|
||||
false
|
||||
}
|
||||
PatKind::Or { pats } => {
|
||||
is_never_pattern = pats.iter().all(|p| p.is_never_pattern());
|
||||
false
|
||||
}
|
||||
_ => true,
|
||||
});
|
||||
is_never_pattern
|
||||
}
|
||||
}
|
||||
|
||||
impl<'tcx> IntoDiagArg for Pat<'tcx> {
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue