@@ -144,7 +144,13 @@ impl<'a, 'tcx> ExprUseVisitor<'a, 'tcx> {
144
144
debug ! ( "delegate_consume(place_with_id={:?})" , place_with_id) ;
145
145
146
146
let mode = copy_or_move ( & self . mc , place_with_id) ;
147
- self . delegate . consume ( place_with_id, diag_expr_id, mode) ;
147
+
148
+ match mode {
149
+ ConsumeMode :: Move => self . delegate . consume ( place_with_id, diag_expr_id, mode) ,
150
+ ConsumeMode :: Copy => {
151
+ self . delegate . borrow ( place_with_id, diag_expr_id, ty:: BorrowKind :: ImmBorrow )
152
+ }
153
+ }
148
154
}
149
155
150
156
fn consume_exprs ( & mut self , exprs : & [ hir:: Expr < ' _ > ] ) {
@@ -653,9 +659,18 @@ impl<'a, 'tcx> ExprUseVisitor<'a, 'tcx> {
653
659
delegate. borrow( place, discr_place. hir_id, bk) ;
654
660
}
655
661
ty:: BindByValue ( ..) => {
656
- let mode = copy_or_move( mc, & place) ;
657
662
debug!( "walk_pat binding consuming pat" ) ;
658
- delegate. consume( place, discr_place. hir_id, mode) ;
663
+ let mode = copy_or_move( mc, & place) ;
664
+ match mode {
665
+ ConsumeMode :: Move => {
666
+ delegate. consume( place, discr_place. hir_id, mode)
667
+ }
668
+ ConsumeMode :: Copy => delegate. borrow(
669
+ place,
670
+ discr_place. hir_id,
671
+ ty:: BorrowKind :: ImmBorrow ,
672
+ ) ,
673
+ }
659
674
}
660
675
}
661
676
}
@@ -773,8 +788,7 @@ impl<'a, 'tcx> ExprUseVisitor<'a, 'tcx> {
773
788
774
789
match capture_info. capture_kind {
775
790
ty:: UpvarCapture :: ByValue ( _) => {
776
- let mode = copy_or_move ( & self . mc , & place_with_id) ;
777
- self . delegate . consume ( & place_with_id, place_with_id. hir_id , mode) ;
791
+ self . delegate_consume ( & place_with_id, place_with_id. hir_id ) ;
778
792
}
779
793
ty:: UpvarCapture :: ByRef ( upvar_borrow) => {
780
794
self . delegate . borrow (
0 commit comments