@@ -45,6 +45,7 @@ pub trait Delegate<'tcx> {
45
45
place_with_id : & PlaceWithHirId < ' tcx > ,
46
46
diag_expr_id : hir:: HirId ,
47
47
bk : ty:: BorrowKind ,
48
+ is_autoref : bool ,
48
49
) ;
49
50
50
51
/// The path at `assignee_place` is being assigned to.
@@ -175,7 +176,7 @@ impl<'a, 'tcx> ExprUseVisitor<'a, 'tcx> {
175
176
debug ! ( "borrow_expr(expr={:?}, bk={:?})" , expr, bk) ;
176
177
177
178
let place_with_id = return_if_err ! ( self . mc. cat_expr( expr) ) ;
178
- self . delegate . borrow ( & place_with_id, place_with_id. hir_id , bk) ;
179
+ self . delegate . borrow ( & place_with_id, place_with_id. hir_id , bk, false ) ;
179
180
180
181
self . walk_expr ( expr)
181
182
}
@@ -558,7 +559,7 @@ impl<'a, 'tcx> ExprUseVisitor<'a, 'tcx> {
558
559
// this is an autoref of `x`.
559
560
adjustment:: Adjust :: Deref ( Some ( ref deref) ) => {
560
561
let bk = ty:: BorrowKind :: from_mutbl ( deref. mutbl ) ;
561
- self . delegate . borrow ( & place_with_id, place_with_id. hir_id , bk) ;
562
+ self . delegate . borrow ( & place_with_id, place_with_id. hir_id , bk, true ) ;
562
563
}
563
564
564
565
adjustment:: Adjust :: Borrow ( ref autoref) => {
@@ -590,13 +591,14 @@ impl<'a, 'tcx> ExprUseVisitor<'a, 'tcx> {
590
591
base_place,
591
592
base_place. hir_id ,
592
593
ty:: BorrowKind :: from_mutbl ( m. into ( ) ) ,
594
+ true ,
593
595
) ;
594
596
}
595
597
596
598
adjustment:: AutoBorrow :: RawPtr ( m) => {
597
599
debug ! ( "walk_autoref: expr.hir_id={} base_place={:?}" , expr. hir_id, base_place) ;
598
600
599
- self . delegate . borrow ( base_place, base_place. hir_id , ty:: BorrowKind :: from_mutbl ( m) ) ;
601
+ self . delegate . borrow ( base_place, base_place. hir_id , ty:: BorrowKind :: from_mutbl ( m) , true ) ;
600
602
}
601
603
}
602
604
}
@@ -669,7 +671,7 @@ impl<'a, 'tcx> ExprUseVisitor<'a, 'tcx> {
669
671
match bm {
670
672
ty:: BindByReference ( m) => {
671
673
let bk = ty:: BorrowKind :: from_mutbl( m) ;
672
- delegate. borrow( place, discr_place. hir_id, bk) ;
674
+ delegate. borrow( place, discr_place. hir_id, bk, false ) ;
673
675
}
674
676
ty:: BindByValue ( ..) => {
675
677
debug!( "walk_pat binding consuming pat" ) ;
@@ -799,6 +801,7 @@ impl<'a, 'tcx> ExprUseVisitor<'a, 'tcx> {
799
801
& place_with_id,
800
802
place_with_id. hir_id ,
801
803
upvar_borrow,
804
+ false ,
802
805
) ;
803
806
}
804
807
}
@@ -837,7 +840,7 @@ fn delegate_consume<'a, 'tcx>(
837
840
match mode {
838
841
ConsumeMode :: Move => delegate. consume ( place_with_id, diag_expr_id) ,
839
842
ConsumeMode :: Copy => {
840
- delegate. borrow ( place_with_id, diag_expr_id, ty:: BorrowKind :: ImmBorrow )
843
+ delegate. borrow ( place_with_id, diag_expr_id, ty:: BorrowKind :: ImmBorrow , false )
841
844
}
842
845
}
843
846
}
0 commit comments