@@ -48,6 +48,14 @@ pub trait Delegate<'tcx> {
4848 is_autoref : bool ,
4949 ) ;
5050
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+
5159 /// The path at `assignee_place` is being assigned to.
5260 /// `diag_expr_id` is the id used for diagnostics (see `consume` for more details).
5361 fn mutate ( & mut self , assignee_place : & PlaceWithHirId < ' tcx > , diag_expr_id : hir:: HirId ) ;
@@ -598,7 +606,12 @@ impl<'a, 'tcx> ExprUseVisitor<'a, 'tcx> {
598606 adjustment:: AutoBorrow :: RawPtr ( m) => {
599607 debug ! ( "walk_autoref: expr.hir_id={} base_place={:?}" , expr. hir_id, base_place) ;
600608
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+ ) ;
602615 }
603616 }
604617 }
@@ -839,9 +852,7 @@ fn delegate_consume<'a, 'tcx>(
839852
840853 match mode {
841854 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) ,
845856 }
846857}
847858
0 commit comments