@@ -324,6 +324,18 @@ impl<'tcx, Cx: TypeInformationCtxt<'tcx>, D: Delegate<'tcx>> ExprUseVisitor<'tcx
324
324
}
325
325
}
326
326
327
+ pub fn consume_clone_or_copy ( & self , place_with_id : & PlaceWithHirId < ' tcx > , diag_expr_id : HirId ) {
328
+ debug ! ( "delegate_consume_or_clone(place_with_id={:?})" , place_with_id) ;
329
+
330
+ if self . cx . type_is_copy_modulo_regions ( place_with_id. place . ty ( ) ) {
331
+ self . delegate . borrow_mut ( ) . copy ( place_with_id, diag_expr_id) ;
332
+ } else if self . cx . type_is_use_cloned_modulo_regions ( place_with_id. place . ty ( ) ) {
333
+ self . delegate . borrow_mut ( ) . use_cloned ( place_with_id, diag_expr_id) ;
334
+ } else {
335
+ self . delegate . borrow_mut ( ) . consume ( place_with_id, diag_expr_id) ;
336
+ }
337
+ }
338
+
327
339
fn consume_exprs ( & self , exprs : & [ hir:: Expr < ' _ > ] ) -> Result < ( ) , Cx :: Error > {
328
340
for expr in exprs {
329
341
self . consume_expr ( expr) ?;
@@ -346,15 +358,7 @@ impl<'tcx, Cx: TypeInformationCtxt<'tcx>, D: Delegate<'tcx>> ExprUseVisitor<'tcx
346
358
debug ! ( "consume_or_clone_expr(expr={:?})" , expr) ;
347
359
348
360
let place_with_id = self . cat_expr ( expr) ?;
349
-
350
- if self . cx . type_is_copy_modulo_regions ( place_with_id. place . ty ( ) ) {
351
- self . delegate . borrow_mut ( ) . copy ( & place_with_id, place_with_id. hir_id ) ;
352
- } else if self . cx . type_is_use_cloned_modulo_regions ( place_with_id. place . ty ( ) ) {
353
- self . delegate . borrow_mut ( ) . use_cloned ( & place_with_id, place_with_id. hir_id ) ;
354
- } else {
355
- self . delegate . borrow_mut ( ) . consume ( & place_with_id, place_with_id. hir_id ) ;
356
- }
357
-
361
+ self . consume_clone_or_copy ( & place_with_id, place_with_id. hir_id ) ;
358
362
self . walk_expr ( expr) ?;
359
363
Ok ( ( ) )
360
364
}
@@ -1132,9 +1136,12 @@ impl<'tcx, Cx: TypeInformationCtxt<'tcx>, D: Delegate<'tcx>> ExprUseVisitor<'tcx
1132
1136
) ;
1133
1137
1134
1138
match capture_info. capture_kind {
1135
- ty:: UpvarCapture :: ByValue | ty :: UpvarCapture :: ByUse => {
1139
+ ty:: UpvarCapture :: ByValue => {
1136
1140
self . consume_or_copy ( & place_with_id, place_with_id. hir_id ) ;
1137
1141
}
1142
+ ty:: UpvarCapture :: ByUse => {
1143
+ self . consume_clone_or_copy ( & place_with_id, place_with_id. hir_id ) ;
1144
+ }
1138
1145
ty:: UpvarCapture :: ByRef ( upvar_borrow) => {
1139
1146
self . delegate . borrow_mut ( ) . borrow (
1140
1147
& place_with_id,
0 commit comments