@@ -3,7 +3,7 @@ use crate::errors::*;
3
3
use rustc_middle:: thir:: visit:: { self , Visitor } ;
4
4
5
5
use rustc_hir as hir;
6
- use rustc_middle:: mir:: { BorrowKind , MutBorrowKind } ;
6
+ use rustc_middle:: mir:: BorrowKind ;
7
7
use rustc_middle:: thir:: * ;
8
8
use rustc_middle:: ty:: print:: with_no_trimmed_paths;
9
9
use rustc_middle:: ty:: { self , ParamEnv , Ty , TyCtxt } ;
@@ -254,9 +254,7 @@ impl<'a, 'tcx> Visitor<'a, 'tcx> for UnsafetyVisitor<'a, 'tcx> {
254
254
) ;
255
255
} ;
256
256
match borrow_kind {
257
- BorrowKind :: Shallow
258
- | BorrowKind :: Shared
259
- | BorrowKind :: Mut { kind : MutBorrowKind :: ClosureCapture } => {
257
+ BorrowKind :: Shallow | BorrowKind :: Shared => {
260
258
if !ty. is_freeze ( self . tcx , self . param_env ) {
261
259
self . requires_unsafe ( pat. span , BorrowOfLayoutConstrainedField ) ;
262
260
}
@@ -442,19 +440,15 @@ impl<'a, 'tcx> Visitor<'a, 'tcx> for UnsafetyVisitor<'a, 'tcx> {
442
440
visit:: walk_expr ( & mut visitor, expr) ;
443
441
if visitor. found {
444
442
match borrow_kind {
445
- BorrowKind :: Shallow
446
- | BorrowKind :: Shared
447
- | BorrowKind :: Mut { kind : MutBorrowKind :: ClosureCapture }
443
+ BorrowKind :: Shallow | BorrowKind :: Shared
448
444
if !self . thir [ arg] . ty . is_freeze ( self . tcx , self . param_env ) =>
449
445
{
450
446
self . requires_unsafe ( expr. span , BorrowOfLayoutConstrainedField )
451
447
}
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 => { }
458
452
}
459
453
}
460
454
}
0 commit comments