@@ -48,6 +48,14 @@ pub trait Delegate<'tcx> {
48
48
is_autoref : bool ,
49
49
) ;
50
50
51
+ /// The value found at `place` is being copied.
52
+ /// `diag_expr_id` is the id used for diagnostics (see `consume` for more details).
53
+ fn copy ( & mut self , place_with_id : & PlaceWithHirId < ' tcx > , diag_expr_id : hir:: HirId ) {
54
+ // In most cases, treating a copy as a borrow is the right thing, so we forward
55
+ // this to the borrow callback by default.
56
+ self . borrow ( place_with_id, diag_expr_id, ty:: BorrowKind :: ImmBorrow , false )
57
+ }
58
+
51
59
/// The path at `assignee_place` is being assigned to.
52
60
/// `diag_expr_id` is the id used for diagnostics (see `consume` for more details).
53
61
fn mutate ( & mut self , assignee_place : & PlaceWithHirId < ' tcx > , diag_expr_id : hir:: HirId ) ;
@@ -598,7 +606,12 @@ impl<'a, 'tcx> ExprUseVisitor<'a, 'tcx> {
598
606
adjustment:: AutoBorrow :: RawPtr ( m) => {
599
607
debug ! ( "walk_autoref: expr.hir_id={} base_place={:?}" , expr. hir_id, base_place) ;
600
608
601
- self . delegate . borrow ( base_place, base_place. hir_id , ty:: BorrowKind :: from_mutbl ( m) , true ) ;
609
+ self . delegate . borrow (
610
+ base_place,
611
+ base_place. hir_id ,
612
+ ty:: BorrowKind :: from_mutbl ( m) ,
613
+ true ,
614
+ ) ;
602
615
}
603
616
}
604
617
}
@@ -839,9 +852,7 @@ fn delegate_consume<'a, 'tcx>(
839
852
840
853
match mode {
841
854
ConsumeMode :: Move => delegate. consume ( place_with_id, diag_expr_id) ,
842
- ConsumeMode :: Copy => {
843
- delegate. borrow ( place_with_id, diag_expr_id, ty:: BorrowKind :: ImmBorrow , false )
844
- }
855
+ ConsumeMode :: Copy => delegate. copy ( place_with_id, diag_expr_id) ,
845
856
}
846
857
}
847
858
0 commit comments