@@ -1059,6 +1059,7 @@ pub fn can_move_expr_to_closure_no_visit<'tcx>(
10591059#[ derive( Debug , Clone , Copy , PartialEq , Eq ) ]
10601060pub enum CaptureKind {
10611061 Value ,
1062+ Use ,
10621063 Ref ( Mutability ) ,
10631064}
10641065impl CaptureKind {
@@ -1071,6 +1072,7 @@ impl std::ops::BitOr for CaptureKind {
10711072 fn bitor ( self , rhs : Self ) -> Self :: Output {
10721073 match ( self , rhs) {
10731074 ( CaptureKind :: Value , _) | ( _, CaptureKind :: Value ) => CaptureKind :: Value ,
1075+ ( CaptureKind :: Use , _) | ( _, CaptureKind :: Use ) => CaptureKind :: Use ,
10741076 ( CaptureKind :: Ref ( Mutability :: Mut ) , CaptureKind :: Ref ( _) )
10751077 | ( CaptureKind :: Ref ( _) , CaptureKind :: Ref ( Mutability :: Mut ) ) => CaptureKind :: Ref ( Mutability :: Mut ) ,
10761078 ( CaptureKind :: Ref ( Mutability :: Not ) , CaptureKind :: Ref ( Mutability :: Not ) ) => CaptureKind :: Ref ( Mutability :: Not ) ,
@@ -1151,7 +1153,7 @@ pub fn capture_local_usage(cx: &LateContext<'_>, e: &Expr<'_>) -> CaptureKind {
11511153 } ,
11521154 ExprKind :: Let ( let_expr) => {
11531155 let mutability = match pat_capture_kind ( cx, let_expr. pat ) {
1154- CaptureKind :: Value => Mutability :: Not ,
1156+ CaptureKind :: Value | CaptureKind :: Use => Mutability :: Not ,
11551157 CaptureKind :: Ref ( m) => m,
11561158 } ;
11571159 return CaptureKind :: Ref ( mutability) ;
@@ -1160,7 +1162,7 @@ pub fn capture_local_usage(cx: &LateContext<'_>, e: &Expr<'_>) -> CaptureKind {
11601162 let mut mutability = Mutability :: Not ;
11611163 for capture in arms. iter ( ) . map ( |arm| pat_capture_kind ( cx, arm. pat ) ) {
11621164 match capture {
1163- CaptureKind :: Value => break ,
1165+ CaptureKind :: Value | CaptureKind :: Use => break ,
11641166 CaptureKind :: Ref ( Mutability :: Mut ) => mutability = Mutability :: Mut ,
11651167 CaptureKind :: Ref ( Mutability :: Not ) => ( ) ,
11661168 }
@@ -1170,7 +1172,7 @@ pub fn capture_local_usage(cx: &LateContext<'_>, e: &Expr<'_>) -> CaptureKind {
11701172 _ => break ,
11711173 } ,
11721174 Node :: LetStmt ( l) => match pat_capture_kind ( cx, l. pat ) {
1173- CaptureKind :: Value => break ,
1175+ CaptureKind :: Value | CaptureKind :: Use => break ,
11741176 capture @ CaptureKind :: Ref ( _) => return capture,
11751177 } ,
11761178 _ => break ,
@@ -1225,6 +1227,8 @@ pub fn can_move_expr_to_closure<'tcx>(cx: &LateContext<'tcx>, expr: &'tcx Expr<'
12251227 if !self . locals . contains ( & local_id) {
12261228 let capture = match capture. info . capture_kind {
12271229 UpvarCapture :: ByValue => CaptureKind :: Value ,
1230+ // FIXME add a CaptureKind::Use
1231+ UpvarCapture :: ByUse => CaptureKind :: Use ,
12281232 UpvarCapture :: ByRef ( kind) => match kind {
12291233 BorrowKind :: Immutable => CaptureKind :: Ref ( Mutability :: Not ) ,
12301234 BorrowKind :: UniqueImmutable | BorrowKind :: Mutable => {
0 commit comments