@@ -44,8 +44,8 @@ use rustc_middle::hir::place::{Place, PlaceBase, PlaceWithHirId, Projection, Pro
44
44
use rustc_middle:: mir:: FakeReadCause ;
45
45
use rustc_middle:: traits:: ObligationCauseCode ;
46
46
use 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 ,
49
49
} ;
50
50
use rustc_middle:: { bug, span_bug} ;
51
51
use rustc_session:: lint;
@@ -646,7 +646,7 @@ impl<'a, 'tcx> FnCtxt<'a, 'tcx> {
646
646
} ,
647
647
648
648
ty:: UpvarCapture :: ByRef (
649
- ty:: BorrowKind :: MutBorrow | ty:: BorrowKind :: UniqueImmBorrow ,
649
+ ty:: BorrowKind :: Mutable | ty:: BorrowKind :: UniqueImmutable ,
650
650
) => {
651
651
match closure_kind {
652
652
ty:: ClosureKind :: Fn => {
@@ -1681,7 +1681,7 @@ impl<'a, 'tcx> FnCtxt<'a, 'tcx> {
1681
1681
ty:: UpvarCapture :: ByValue
1682
1682
}
1683
1683
hir:: CaptureBy :: Value { .. } | hir:: CaptureBy :: Ref => {
1684
- ty:: UpvarCapture :: ByRef ( ty :: ImmBorrow )
1684
+ ty:: UpvarCapture :: ByRef ( BorrowKind :: Immutable )
1685
1685
}
1686
1686
}
1687
1687
}
@@ -1869,7 +1869,7 @@ fn should_reborrow_from_env_of_parent_coroutine_closure<'tcx>(
1869
1869
Some ( Projection { kind: ProjectionKind :: Deref , .. } )
1870
1870
) )
1871
1871
// (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 ) )
1873
1873
}
1874
1874
1875
1875
/// 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> {
1984
1984
1985
1985
// We need to restrict Fake Read precision to avoid fake reading unsafe code,
1986
1986
// 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 ) ;
1988
1988
1989
1989
let ( place, _) = restrict_capture_precision ( place. place . clone ( ) , dummy_capture_kind) ;
1990
1990
@@ -2025,7 +2025,7 @@ impl<'tcx> euv::Delegate<'tcx> for InferBorrowKind<'tcx> {
2025
2025
2026
2026
// Raw pointers don't inherit mutability
2027
2027
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 ) ;
2029
2029
}
2030
2030
2031
2031
self . capture_information . push ( ( place, ty:: CaptureInfo {
@@ -2037,7 +2037,7 @@ impl<'tcx> euv::Delegate<'tcx> for InferBorrowKind<'tcx> {
2037
2037
2038
2038
#[ instrument( skip( self ) , level = "debug" ) ]
2039
2039
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 ) ;
2041
2041
}
2042
2042
}
2043
2043
@@ -2331,16 +2331,16 @@ fn determine_capture_info(
2331
2331
( ty:: UpvarCapture :: ByRef ( ref_a) , ty:: UpvarCapture :: ByRef ( ref_b) ) => {
2332
2332
match ( ref_a, ref_b) {
2333
2333
// 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,
2336
2336
2337
2337
// 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,
2340
2340
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 ) => {
2344
2344
bug ! ( "Expected unequal capture kinds" ) ;
2345
2345
}
2346
2346
}
@@ -2367,12 +2367,12 @@ fn truncate_place_to_len_and_update_capture_kind<'tcx>(
2367
2367
// Note that if the place contained Deref of a raw pointer it would've not been MutBorrow, so
2368
2368
// we don't need to worry about that case here.
2369
2369
match curr_mode {
2370
- ty:: UpvarCapture :: ByRef ( ty:: BorrowKind :: MutBorrow ) => {
2370
+ ty:: UpvarCapture :: ByRef ( ty:: BorrowKind :: Mutable ) => {
2371
2371
for i in len..place. projections . len ( ) {
2372
2372
if place. projections [ i] . kind == ProjectionKind :: Deref
2373
2373
&& is_mut_ref ( place. ty_before_projection ( i) )
2374
2374
{
2375
- * curr_mode = ty:: UpvarCapture :: ByRef ( ty:: BorrowKind :: UniqueImmBorrow ) ;
2375
+ * curr_mode = ty:: UpvarCapture :: ByRef ( ty:: BorrowKind :: UniqueImmutable ) ;
2376
2376
break ;
2377
2377
}
2378
2378
}
0 commit comments