@@ -666,7 +666,9 @@ impl<'a, 'tcx> FnCtxt<'a, 'tcx> {
666666 origin = updated. 1 ;
667667
668668 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+ }
670672 hir:: CaptureBy :: Ref => adjust_for_non_move_closure ( place, capture_kind) ,
671673 } ;
672674
@@ -1161,7 +1163,7 @@ impl<'a, 'tcx> FnCtxt<'a, 'tcx> {
11611163
11621164 let ty = match closure_clause {
11631165 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 { .. } => {
11651167 // For non move closure the capture kind is the max capture kind of all captures
11661168 // according to the ordering ImmBorrow < UniqueImmBorrow < MutBorrow < ByValue
11671169 let mut max_capture_info = root_var_min_capture_list. first ( ) . unwrap ( ) . info ;
@@ -1288,7 +1290,7 @@ impl<'a, 'tcx> FnCtxt<'a, 'tcx> {
12881290 . insert ( UpvarMigrationInfo :: CapturingNothing { use_span : upvar. span } ) ;
12891291 return Some ( diagnostics_info) ;
12901292 }
1291- hir:: CaptureBy :: Ref => { }
1293+ hir:: CaptureBy :: Ref | hir :: CaptureBy :: Use { .. } => { }
12921294 }
12931295
12941296 return None ;
@@ -1685,10 +1687,12 @@ impl<'a, 'tcx> FnCtxt<'a, 'tcx> {
16851687 //
16861688 // If the data will be moved out of this place, then the place will be truncated
16871689 // 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+ {
16891693 ty:: UpvarCapture :: ByValue
16901694 }
1691- hir:: CaptureBy :: Value { .. } | hir:: CaptureBy :: Ref => {
1695+ hir:: CaptureBy :: Value { .. } | hir:: CaptureBy :: Use { .. } | hir :: CaptureBy :: Ref => {
16921696 ty:: UpvarCapture :: ByRef ( BorrowKind :: Immutable )
16931697 }
16941698 }
0 commit comments