diff options
| author | Michael Goulet <michael@errs.io> | 2024-09-18 17:05:44 -0400 |
|---|---|---|
| committer | Michael Goulet <michael@errs.io> | 2024-09-18 19:17:38 -0400 |
| commit | e138e8760da3d75def4d23567ae944d65b2d4e89 (patch) | |
| tree | 3a527eefa0e73b9c050c3ae9001c6ec68795618c /compiler/rustc_mir_build/src | |
| parent | f79a912d9edc3ad4db910c0e93672ed5c65133fa (diff) | |
| download | rust-e138e8760da3d75def4d23567ae944d65b2d4e89.tar.gz rust-e138e8760da3d75def4d23567ae944d65b2d4e89.zip | |
Never patterns constitute a read for unsafety
Diffstat (limited to 'compiler/rustc_mir_build/src')
| -rw-r--r-- | compiler/rustc_mir_build/src/check_unsafety.rs | 9 |
1 files changed, 5 insertions, 4 deletions
diff --git a/compiler/rustc_mir_build/src/check_unsafety.rs b/compiler/rustc_mir_build/src/check_unsafety.rs index c7fcfe3ce2a..198698d06fa 100644 --- a/compiler/rustc_mir_build/src/check_unsafety.rs +++ b/compiler/rustc_mir_build/src/check_unsafety.rs @@ -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 { .. } | |
