]> git.lizzy.rs Git - rust.git/blobdiff - compiler/rustc_mir_build/src/check_unsafety.rs
Auto merge of #91837 - Kobzol:stable-hash-map-avoid-sort, r=the8472
[rust.git] / compiler / rustc_mir_build / src / check_unsafety.rs
index 0e82b187201422d4983f105718266d74e946fb1d..7940bd1f33dc1bb35eacf2459708a02195c6d657 100644 (file)
@@ -256,23 +256,22 @@ fn visit_pat(&mut self, pat: &Pat<'tcx>) {
             }
             PatKind::Binding { mode: BindingMode::ByRef(borrow_kind), ty, .. } => {
                 if self.inside_adt {
-                    if let ty::Ref(_, ty, _) = ty.kind() {
-                        match borrow_kind {
-                            BorrowKind::Shallow | BorrowKind::Shared | BorrowKind::Unique => {
-                                if !ty.is_freeze(self.tcx.at(pat.span), self.param_env) {
-                                    self.requires_unsafe(pat.span, BorrowOfLayoutConstrainedField);
-                                }
-                            }
-                            BorrowKind::Mut { .. } => {
-                                self.requires_unsafe(pat.span, MutationOfLayoutConstrainedField);
-                            }
-                        }
-                    } else {
+                    let ty::Ref(_, ty, _) = ty.kind() else {
                         span_bug!(
                             pat.span,
                             "BindingMode::ByRef in pattern, but found non-reference type {}",
                             ty
                         );
+                    };
+                    match borrow_kind {
+                        BorrowKind::Shallow | BorrowKind::Shared | BorrowKind::Unique => {
+                            if !ty.is_freeze(self.tcx.at(pat.span), self.param_env) {
+                                self.requires_unsafe(pat.span, BorrowOfLayoutConstrainedField);
+                            }
+                        }
+                        BorrowKind::Mut { .. } => {
+                            self.requires_unsafe(pat.span, MutationOfLayoutConstrainedField);
+                        }
                     }
                 }
                 visit::walk_pat(self, pat);