@@ -456,27 +456,25 @@ impl<'a, 'tcx> Visitor<'a, 'tcx> for UnsafetyVisitor<'a, 'tcx> {
456456 return ; // we have already visited everything by now
457457 }
458458 }
459- ExprKind :: Borrow { borrow_kind, arg } => match borrow_kind {
460- BorrowKind :: Shallow | BorrowKind :: Shared | BorrowKind :: Unique => {
461- if !self . thir [ arg]
462- . ty
463- . is_freeze ( self . tcx . at ( self . thir [ arg] . span ) , self . param_env )
464- {
465- let mut visitor = LayoutConstrainedPlaceVisitor :: new ( self . thir , self . tcx ) ;
466- visit:: walk_expr ( & mut visitor, expr) ;
467- if visitor. found {
468- self . requires_unsafe ( expr. span , BorrowOfLayoutConstrainedField ) ;
459+ ExprKind :: Borrow { borrow_kind, arg } => {
460+ let mut visitor = LayoutConstrainedPlaceVisitor :: new ( self . thir , self . tcx ) ;
461+ visit:: walk_expr ( & mut visitor, expr) ;
462+ if visitor. found {
463+ match borrow_kind {
464+ BorrowKind :: Shallow | BorrowKind :: Shared | BorrowKind :: Unique
465+ if !self . thir [ arg]
466+ . ty
467+ . is_freeze ( self . tcx . at ( self . thir [ arg] . span ) , self . param_env ) =>
468+ {
469+ self . requires_unsafe ( expr. span , BorrowOfLayoutConstrainedField )
469470 }
471+ BorrowKind :: Mut { .. } => {
472+ self . requires_unsafe ( expr. span , MutationOfLayoutConstrainedField )
473+ }
474+ BorrowKind :: Shallow | BorrowKind :: Shared | BorrowKind :: Unique => { }
470475 }
471476 }
472- BorrowKind :: Mut { .. } => {
473- let mut visitor = LayoutConstrainedPlaceVisitor :: new ( self . thir , self . tcx ) ;
474- visit:: walk_expr ( & mut visitor, expr) ;
475- if visitor. found {
476- self . requires_unsafe ( expr. span , MutationOfLayoutConstrainedField ) ;
477- }
478- }
479- } ,
477+ }
480478 _ => { }
481479 }
482480 visit:: walk_expr ( self , expr) ;
0 commit comments