@@ -666,7 +666,9 @@ impl<'a, 'tcx> FnCtxt<'a, 'tcx> {
666
666
origin = updated. 1 ;
667
667
668
668
let ( place, capture_kind) = match capture_clause {
669
- hir:: CaptureBy :: Value { .. } => adjust_for_move_closure ( place, capture_kind) ,
669
+ hir:: CaptureBy :: Value { .. } | hir:: CaptureBy :: Use { .. } => {
670
+ adjust_for_move_closure ( place, capture_kind)
671
+ }
670
672
hir:: CaptureBy :: Ref => adjust_for_non_move_closure ( place, capture_kind) ,
671
673
} ;
672
674
@@ -1161,7 +1163,7 @@ impl<'a, 'tcx> FnCtxt<'a, 'tcx> {
1161
1163
1162
1164
let ty = match closure_clause {
1163
1165
hir:: CaptureBy :: Value { .. } => ty, // For move closure the capture kind should be by value
1164
- hir:: CaptureBy :: Ref => {
1166
+ hir:: CaptureBy :: Ref | hir :: CaptureBy :: Use { .. } => {
1165
1167
// For non move closure the capture kind is the max capture kind of all captures
1166
1168
// according to the ordering ImmBorrow < UniqueImmBorrow < MutBorrow < ByValue
1167
1169
let mut max_capture_info = root_var_min_capture_list. first ( ) . unwrap ( ) . info ;
@@ -1288,7 +1290,7 @@ impl<'a, 'tcx> FnCtxt<'a, 'tcx> {
1288
1290
. insert ( UpvarMigrationInfo :: CapturingNothing { use_span : upvar. span } ) ;
1289
1291
return Some ( diagnostics_info) ;
1290
1292
}
1291
- hir:: CaptureBy :: Ref => { }
1293
+ hir:: CaptureBy :: Ref | hir :: CaptureBy :: Use { .. } => { }
1292
1294
}
1293
1295
1294
1296
return None ;
@@ -1685,10 +1687,12 @@ impl<'a, 'tcx> FnCtxt<'a, 'tcx> {
1685
1687
//
1686
1688
// If the data will be moved out of this place, then the place will be truncated
1687
1689
// at the first Deref in `adjust_for_move_closure` and then moved into the closure.
1688
- hir:: CaptureBy :: Value { .. } if !place. deref_tys ( ) . any ( Ty :: is_ref) => {
1690
+ hir:: CaptureBy :: Value { .. } | hir:: CaptureBy :: Use { .. }
1691
+ if !place. deref_tys ( ) . any ( Ty :: is_ref) =>
1692
+ {
1689
1693
ty:: UpvarCapture :: ByValue
1690
1694
}
1691
- hir:: CaptureBy :: Value { .. } | hir:: CaptureBy :: Ref => {
1695
+ hir:: CaptureBy :: Value { .. } | hir:: CaptureBy :: Use { .. } | hir :: CaptureBy :: Ref => {
1692
1696
ty:: UpvarCapture :: ByRef ( BorrowKind :: Immutable )
1693
1697
}
1694
1698
}
0 commit comments