@@ -44,8 +44,8 @@ use rustc_middle::hir::place::{Place, PlaceBase, PlaceWithHirId, Projection, Pro
4444use rustc_middle:: mir:: FakeReadCause ;
4545use rustc_middle:: traits:: ObligationCauseCode ;
4646use rustc_middle:: ty:: {
47- self , ClosureSizeProfileData , Ty , TyCtxt , TypeVisitableExt as _, TypeckResults , UpvarArgs ,
48- UpvarCapture ,
47+ self , BorrowKind , ClosureSizeProfileData , Ty , TyCtxt , TypeVisitableExt as _, TypeckResults ,
48+ UpvarArgs , UpvarCapture ,
4949} ;
5050use rustc_middle:: { bug, span_bug} ;
5151use rustc_session:: lint;
@@ -646,7 +646,7 @@ impl<'a, 'tcx> FnCtxt<'a, 'tcx> {
646646 } ,
647647
648648 ty:: UpvarCapture :: ByRef (
649- ty:: BorrowKind :: MutBorrow | ty:: BorrowKind :: UniqueImmBorrow ,
649+ ty:: BorrowKind :: Mutable | ty:: BorrowKind :: UniqueImmutable ,
650650 ) => {
651651 match closure_kind {
652652 ty:: ClosureKind :: Fn => {
@@ -1681,7 +1681,7 @@ impl<'a, 'tcx> FnCtxt<'a, 'tcx> {
16811681 ty:: UpvarCapture :: ByValue
16821682 }
16831683 hir:: CaptureBy :: Value { .. } | hir:: CaptureBy :: Ref => {
1684- ty:: UpvarCapture :: ByRef ( ty :: ImmBorrow )
1684+ ty:: UpvarCapture :: ByRef ( BorrowKind :: Immutable )
16851685 }
16861686 }
16871687 }
@@ -1869,7 +1869,7 @@ fn should_reborrow_from_env_of_parent_coroutine_closure<'tcx>(
18691869 Some ( Projection { kind: ProjectionKind :: Deref , .. } )
18701870 ) )
18711871 // (2.)
1872- || matches ! ( child_capture. info. capture_kind, UpvarCapture :: ByRef ( ty:: BorrowKind :: MutBorrow ) )
1872+ || matches ! ( child_capture. info. capture_kind, UpvarCapture :: ByRef ( ty:: BorrowKind :: Mutable ) )
18731873}
18741874
18751875/// Truncate the capture so that the place being borrowed is in accordance with RFC 1240,
@@ -1984,7 +1984,7 @@ impl<'tcx> euv::Delegate<'tcx> for InferBorrowKind<'tcx> {
19841984
19851985 // We need to restrict Fake Read precision to avoid fake reading unsafe code,
19861986 // such as deref of a raw pointer.
1987- let dummy_capture_kind = ty:: UpvarCapture :: ByRef ( ty:: BorrowKind :: ImmBorrow ) ;
1987+ let dummy_capture_kind = ty:: UpvarCapture :: ByRef ( ty:: BorrowKind :: Immutable ) ;
19881988
19891989 let ( place, _) = restrict_capture_precision ( place. place . clone ( ) , dummy_capture_kind) ;
19901990
@@ -2025,7 +2025,7 @@ impl<'tcx> euv::Delegate<'tcx> for InferBorrowKind<'tcx> {
20252025
20262026 // Raw pointers don't inherit mutability
20272027 if place_with_id. place . deref_tys ( ) . any ( Ty :: is_unsafe_ptr) {
2028- capture_kind = ty:: UpvarCapture :: ByRef ( ty:: BorrowKind :: ImmBorrow ) ;
2028+ capture_kind = ty:: UpvarCapture :: ByRef ( ty:: BorrowKind :: Immutable ) ;
20292029 }
20302030
20312031 self . capture_information . push ( ( place, ty:: CaptureInfo {
@@ -2037,7 +2037,7 @@ impl<'tcx> euv::Delegate<'tcx> for InferBorrowKind<'tcx> {
20372037
20382038 #[ instrument( skip( self ) , level = "debug" ) ]
20392039 fn mutate ( & mut self , assignee_place : & PlaceWithHirId < ' tcx > , diag_expr_id : HirId ) {
2040- self . borrow ( assignee_place, diag_expr_id, ty:: BorrowKind :: MutBorrow ) ;
2040+ self . borrow ( assignee_place, diag_expr_id, ty:: BorrowKind :: Mutable ) ;
20412041 }
20422042}
20432043
@@ -2331,16 +2331,16 @@ fn determine_capture_info(
23312331 ( ty:: UpvarCapture :: ByRef ( ref_a) , ty:: UpvarCapture :: ByRef ( ref_b) ) => {
23322332 match ( ref_a, ref_b) {
23332333 // Take LHS:
2334- ( ty :: UniqueImmBorrow | ty :: MutBorrow , ty :: ImmBorrow )
2335- | ( ty :: MutBorrow , ty :: UniqueImmBorrow ) => capture_info_a,
2334+ ( BorrowKind :: UniqueImmutable | BorrowKind :: Mutable , BorrowKind :: Immutable )
2335+ | ( BorrowKind :: Mutable , BorrowKind :: UniqueImmutable ) => capture_info_a,
23362336
23372337 // Take RHS:
2338- ( ty :: ImmBorrow , ty :: UniqueImmBorrow | ty :: MutBorrow )
2339- | ( ty :: UniqueImmBorrow , ty :: MutBorrow ) => capture_info_b,
2338+ ( BorrowKind :: Immutable , BorrowKind :: UniqueImmutable | BorrowKind :: Mutable )
2339+ | ( BorrowKind :: UniqueImmutable , BorrowKind :: Mutable ) => capture_info_b,
23402340
2341- ( ty :: ImmBorrow , ty :: ImmBorrow )
2342- | ( ty :: UniqueImmBorrow , ty :: UniqueImmBorrow )
2343- | ( ty :: MutBorrow , ty :: MutBorrow ) => {
2341+ ( BorrowKind :: Immutable , BorrowKind :: Immutable )
2342+ | ( BorrowKind :: UniqueImmutable , BorrowKind :: UniqueImmutable )
2343+ | ( BorrowKind :: Mutable , BorrowKind :: Mutable ) => {
23442344 bug ! ( "Expected unequal capture kinds" ) ;
23452345 }
23462346 }
@@ -2367,12 +2367,12 @@ fn truncate_place_to_len_and_update_capture_kind<'tcx>(
23672367 // Note that if the place contained Deref of a raw pointer it would've not been MutBorrow, so
23682368 // we don't need to worry about that case here.
23692369 match curr_mode {
2370- ty:: UpvarCapture :: ByRef ( ty:: BorrowKind :: MutBorrow ) => {
2370+ ty:: UpvarCapture :: ByRef ( ty:: BorrowKind :: Mutable ) => {
23712371 for i in len..place. projections . len ( ) {
23722372 if place. projections [ i] . kind == ProjectionKind :: Deref
23732373 && is_mut_ref ( place. ty_before_projection ( i) )
23742374 {
2375- * curr_mode = ty:: UpvarCapture :: ByRef ( ty:: BorrowKind :: UniqueImmBorrow ) ;
2375+ * curr_mode = ty:: UpvarCapture :: ByRef ( ty:: BorrowKind :: UniqueImmutable ) ;
23762376 break ;
23772377 }
23782378 }
0 commit comments