Never patterns constitute a read for unsafety
This commit is contained in:
parent
f79a912d9e
commit
e138e8760d
3 changed files with 41 additions and 4 deletions
|
@ -315,14 +315,15 @@ impl<'a, 'tcx> Visitor<'a, 'tcx> for UnsafetyVisitor<'a, 'tcx> {
|
|||
| PatKind::DerefPattern { .. }
|
||||
| PatKind::Range { .. }
|
||||
| PatKind::Slice { .. }
|
||||
| PatKind::Array { .. } => {
|
||||
| PatKind::Array { .. }
|
||||
// Never constitutes a witness of uninhabitedness.
|
||||
| PatKind::Never => {
|
||||
self.requires_unsafe(pat.span, AccessToUnionField);
|
||||
return; // we can return here since this already requires unsafe
|
||||
}
|
||||
// wildcard/never don't take anything
|
||||
// wildcard doesn't read anything.
|
||||
PatKind::Wild |
|
||||
PatKind::Never |
|
||||
// these just wrap other patterns
|
||||
// these just wrap other patterns, which we recurse on below.
|
||||
PatKind::Or { .. } |
|
||||
PatKind::InlineConstant { .. } |
|
||||
PatKind::AscribeUserType { .. } |
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue