@@ -670,7 +670,9 @@ impl<'a, 'tcx> FnCtxt<'a, 'tcx> {
670670 origin = updated. 1 ;
671671
672672 let ( place, capture_kind) = match capture_clause {
673- hir:: CaptureBy :: Value { .. } => adjust_for_move_closure ( place, capture_kind) ,
673+ hir:: CaptureBy :: Value { .. } | hir:: CaptureBy :: Use { .. } => {
674+ adjust_for_move_closure ( place, capture_kind)
675+ }
674676 hir:: CaptureBy :: Ref => adjust_for_non_move_closure ( place, capture_kind) ,
675677 } ;
676678
@@ -1165,7 +1167,7 @@ impl<'a, 'tcx> FnCtxt<'a, 'tcx> {
11651167
11661168 let ty = match closure_clause {
11671169 hir:: CaptureBy :: Value { .. } => ty, // For move closure the capture kind should be by value
1168- hir:: CaptureBy :: Ref => {
1170+ hir:: CaptureBy :: Ref | hir :: CaptureBy :: Use { .. } => {
11691171 // For non move closure the capture kind is the max capture kind of all captures
11701172 // according to the ordering ImmBorrow < UniqueImmBorrow < MutBorrow < ByValue
11711173 let mut max_capture_info = root_var_min_capture_list. first ( ) . unwrap ( ) . info ;
@@ -1292,7 +1294,7 @@ impl<'a, 'tcx> FnCtxt<'a, 'tcx> {
12921294 . insert ( UpvarMigrationInfo :: CapturingNothing { use_span : upvar. span } ) ;
12931295 return Some ( diagnostics_info) ;
12941296 }
1295- hir:: CaptureBy :: Ref => { }
1297+ hir:: CaptureBy :: Ref | hir :: CaptureBy :: Use { .. } => { }
12961298 }
12971299
12981300 return None ;
@@ -1689,10 +1691,12 @@ impl<'a, 'tcx> FnCtxt<'a, 'tcx> {
16891691 //
16901692 // If the data will be moved out of this place, then the place will be truncated
16911693 // at the first Deref in `adjust_for_move_closure` and then moved into the closure.
1692- hir:: CaptureBy :: Value { .. } if !place. deref_tys ( ) . any ( Ty :: is_ref) => {
1694+ hir:: CaptureBy :: Value { .. } | hir:: CaptureBy :: Use { .. }
1695+ if !place. deref_tys ( ) . any ( Ty :: is_ref) =>
1696+ {
16931697 ty:: UpvarCapture :: ByValue
16941698 }
1695- hir:: CaptureBy :: Value { .. } | hir:: CaptureBy :: Ref => {
1699+ hir:: CaptureBy :: Value { .. } | hir:: CaptureBy :: Use { .. } | hir :: CaptureBy :: Ref => {
16961700 ty:: UpvarCapture :: ByRef ( BorrowKind :: Immutable )
16971701 }
16981702 }
0 commit comments