@@ -3,7 +3,7 @@ use crate::errors::*;
33use rustc_middle:: thir:: visit:: { self , Visitor } ;
44
55use rustc_hir as hir;
6- use rustc_middle:: mir:: { BorrowKind , MutBorrowKind } ;
6+ use rustc_middle:: mir:: BorrowKind ;
77use rustc_middle:: thir:: * ;
88use rustc_middle:: ty:: print:: with_no_trimmed_paths;
99use rustc_middle:: ty:: { self , ParamEnv , Ty , TyCtxt } ;
@@ -254,9 +254,7 @@ impl<'a, 'tcx> Visitor<'a, 'tcx> for UnsafetyVisitor<'a, 'tcx> {
254254 ) ;
255255 } ;
256256 match borrow_kind {
257- BorrowKind :: Shallow
258- | BorrowKind :: Shared
259- | BorrowKind :: Mut { kind : MutBorrowKind :: ClosureCapture } => {
257+ BorrowKind :: Shallow | BorrowKind :: Shared => {
260258 if !ty. is_freeze ( self . tcx , self . param_env ) {
261259 self . requires_unsafe ( pat. span , BorrowOfLayoutConstrainedField ) ;
262260 }
@@ -442,19 +440,15 @@ impl<'a, 'tcx> Visitor<'a, 'tcx> for UnsafetyVisitor<'a, 'tcx> {
442440 visit:: walk_expr ( & mut visitor, expr) ;
443441 if visitor. found {
444442 match borrow_kind {
445- BorrowKind :: Shallow
446- | BorrowKind :: Shared
447- | BorrowKind :: Mut { kind : MutBorrowKind :: ClosureCapture }
443+ BorrowKind :: Shallow | BorrowKind :: Shared
448444 if !self . thir [ arg] . ty . is_freeze ( self . tcx , self . param_env ) =>
449445 {
450446 self . requires_unsafe ( expr. span , BorrowOfLayoutConstrainedField )
451447 }
452- BorrowKind :: Mut {
453- kind : MutBorrowKind :: Default | MutBorrowKind :: TwoPhaseBorrow ,
454- } => self . requires_unsafe ( expr. span , MutationOfLayoutConstrainedField ) ,
455- BorrowKind :: Shallow
456- | BorrowKind :: Shared
457- | BorrowKind :: Mut { kind : MutBorrowKind :: ClosureCapture } => { }
448+ BorrowKind :: Mut { .. } => {
449+ self . requires_unsafe ( expr. span , MutationOfLayoutConstrainedField )
450+ }
451+ BorrowKind :: Shallow | BorrowKind :: Shared => { }
458452 }
459453 }
460454 }
0 commit comments