@@ -1042,6 +1042,7 @@ pub fn can_move_expr_to_closure_no_visit<'tcx>(
10421042#[ derive( Debug , Clone , Copy , PartialEq , Eq ) ]
10431043pub enum CaptureKind {
10441044 Value ,
1045+ Use ,
10451046 Ref ( Mutability ) ,
10461047}
10471048impl CaptureKind {
@@ -1054,6 +1055,7 @@ impl std::ops::BitOr for CaptureKind {
10541055 fn bitor ( self , rhs : Self ) -> Self :: Output {
10551056 match ( self , rhs) {
10561057 ( CaptureKind :: Value , _) | ( _, CaptureKind :: Value ) => CaptureKind :: Value ,
1058+ ( CaptureKind :: Use , _) | ( _, CaptureKind :: Use ) => CaptureKind :: Use ,
10571059 ( CaptureKind :: Ref ( Mutability :: Mut ) , CaptureKind :: Ref ( _) )
10581060 | ( CaptureKind :: Ref ( _) , CaptureKind :: Ref ( Mutability :: Mut ) ) => CaptureKind :: Ref ( Mutability :: Mut ) ,
10591061 ( CaptureKind :: Ref ( Mutability :: Not ) , CaptureKind :: Ref ( Mutability :: Not ) ) => CaptureKind :: Ref ( Mutability :: Not ) ,
@@ -1134,7 +1136,7 @@ pub fn capture_local_usage(cx: &LateContext<'_>, e: &Expr<'_>) -> CaptureKind {
11341136 } ,
11351137 ExprKind :: Let ( let_expr) => {
11361138 let mutability = match pat_capture_kind ( cx, let_expr. pat ) {
1137- CaptureKind :: Value => Mutability :: Not ,
1139+ CaptureKind :: Value | CaptureKind :: Use => Mutability :: Not ,
11381140 CaptureKind :: Ref ( m) => m,
11391141 } ;
11401142 return CaptureKind :: Ref ( mutability) ;
@@ -1143,7 +1145,7 @@ pub fn capture_local_usage(cx: &LateContext<'_>, e: &Expr<'_>) -> CaptureKind {
11431145 let mut mutability = Mutability :: Not ;
11441146 for capture in arms. iter ( ) . map ( |arm| pat_capture_kind ( cx, arm. pat ) ) {
11451147 match capture {
1146- CaptureKind :: Value => break ,
1148+ CaptureKind :: Value | CaptureKind :: Use => break ,
11471149 CaptureKind :: Ref ( Mutability :: Mut ) => mutability = Mutability :: Mut ,
11481150 CaptureKind :: Ref ( Mutability :: Not ) => ( ) ,
11491151 }
@@ -1153,7 +1155,7 @@ pub fn capture_local_usage(cx: &LateContext<'_>, e: &Expr<'_>) -> CaptureKind {
11531155 _ => break ,
11541156 } ,
11551157 Node :: LetStmt ( l) => match pat_capture_kind ( cx, l. pat ) {
1156- CaptureKind :: Value => break ,
1158+ CaptureKind :: Value | CaptureKind :: Use => break ,
11571159 capture @ CaptureKind :: Ref ( _) => return capture,
11581160 } ,
11591161 _ => break ,
@@ -1208,6 +1210,8 @@ pub fn can_move_expr_to_closure<'tcx>(cx: &LateContext<'tcx>, expr: &'tcx Expr<'
12081210 if !self . locals . contains ( & local_id) {
12091211 let capture = match capture. info . capture_kind {
12101212 UpvarCapture :: ByValue => CaptureKind :: Value ,
1213+ // FIXME add a CaptureKind::Use
1214+ UpvarCapture :: ByUse => CaptureKind :: Use ,
12111215 UpvarCapture :: ByRef ( kind) => match kind {
12121216 BorrowKind :: Immutable => CaptureKind :: Ref ( Mutability :: Not ) ,
12131217 BorrowKind :: UniqueImmutable | BorrowKind :: Mutable => {
0 commit comments