@@ -409,7 +409,7 @@ impl<'a, 'tcx> FnCtxt<'a, 'tcx> {
409
409
} ;
410
410
411
411
let updated = match capture_info. capture_kind {
412
- ty:: UpvarCapture :: ByValue ( .. ) => match closure_kind {
412
+ ty:: UpvarCapture :: ByValue => match closure_kind {
413
413
ty:: ClosureKind :: Fn | ty:: ClosureKind :: FnMut => {
414
414
( ty:: ClosureKind :: FnOnce , Some ( ( usage_span, place. clone ( ) ) ) )
415
415
}
@@ -1086,7 +1086,7 @@ impl<'a, 'tcx> FnCtxt<'a, 'tcx> {
1086
1086
for captured_place in root_var_min_capture_list. iter ( ) {
1087
1087
match captured_place. info . capture_kind {
1088
1088
// Only care about captures that are moved into the closure
1089
- ty:: UpvarCapture :: ByValue ( .. ) => {
1089
+ ty:: UpvarCapture :: ByValue => {
1090
1090
projections_list. push ( captured_place. place . projections . as_slice ( ) ) ;
1091
1091
diagnostics_info. insert ( UpvarMigrationInfo :: CapturingPrecise {
1092
1092
source_expr : captured_place. info . path_expr_id ,
@@ -1481,7 +1481,7 @@ impl<'a, 'tcx> FnCtxt<'a, 'tcx> {
1481
1481
// at the first Deref in `adjust_upvar_borrow_kind_for_consume` and then moved into
1482
1482
// the closure.
1483
1483
hir:: CaptureBy :: Value if !place. deref_tys ( ) . any ( ty:: TyS :: is_ref) => {
1484
- ty:: UpvarCapture :: ByValue ( None )
1484
+ ty:: UpvarCapture :: ByValue
1485
1485
}
1486
1486
hir:: CaptureBy :: Value | hir:: CaptureBy :: Ref => {
1487
1487
let origin = UpvarRegion ( upvar_id, closure_span) ;
@@ -1678,7 +1678,7 @@ fn apply_capture_kind_on_capture_ty<'tcx>(
1678
1678
capture_kind : UpvarCapture < ' tcx > ,
1679
1679
) -> Ty < ' tcx > {
1680
1680
match capture_kind {
1681
- ty:: UpvarCapture :: ByValue ( _ ) => ty,
1681
+ ty:: UpvarCapture :: ByValue => ty,
1682
1682
ty:: UpvarCapture :: ByRef ( borrow) => tcx
1683
1683
. mk_ref ( borrow. region , ty:: TypeAndMut { ty : ty, mutbl : borrow. kind . to_mutbl_lossy ( ) } ) ,
1684
1684
}
@@ -1756,12 +1756,10 @@ impl<'a, 'tcx> InferBorrowKind<'a, 'tcx> {
1756
1756
1757
1757
debug ! ( ?upvar_id) ;
1758
1758
1759
- let usage_span = tcx. hir ( ) . span ( diag_expr_id) ;
1760
-
1761
1759
let capture_info = ty:: CaptureInfo {
1762
1760
capture_kind_expr_id : Some ( diag_expr_id) ,
1763
1761
path_expr_id : Some ( diag_expr_id) ,
1764
- capture_kind : ty:: UpvarCapture :: ByValue ( Some ( usage_span ) ) ,
1762
+ capture_kind : ty:: UpvarCapture :: ByValue ,
1765
1763
} ;
1766
1764
1767
1765
let curr_info = self . capture_information [ & place_with_id. place ] ;
@@ -1841,7 +1839,7 @@ impl<'a, 'tcx> InferBorrowKind<'a, 'tcx> {
1841
1839
1842
1840
debug ! ( ?curr_capture_info) ;
1843
1841
1844
- if let ty:: UpvarCapture :: ByValue ( _ ) = curr_capture_info. capture_kind {
1842
+ if let ty:: UpvarCapture :: ByValue = curr_capture_info. capture_kind {
1845
1843
// It's already captured by value, we don't need to do anything here
1846
1844
return ;
1847
1845
} else if let ty:: UpvarCapture :: ByRef ( curr_upvar_borrow) = curr_capture_info. capture_kind {
@@ -1961,7 +1959,7 @@ impl<'a, 'tcx> euv::Delegate<'tcx> for InferBorrowKind<'a, 'tcx> {
1961
1959
} ,
1962
1960
1963
1961
// Just truncating the place will never cause capture kind to be updated to ByValue
1964
- ty:: UpvarCapture :: ByValue ( .. ) => unreachable ! ( ) ,
1962
+ ty:: UpvarCapture :: ByValue => unreachable ! ( ) ,
1965
1963
}
1966
1964
}
1967
1965
@@ -1980,7 +1978,7 @@ fn restrict_precision_for_drop_types<'a, 'tcx>(
1980
1978
) -> ( Place < ' tcx > , ty:: UpvarCapture < ' tcx > ) {
1981
1979
let is_copy_type = fcx. infcx . type_is_copy_modulo_regions ( fcx. param_env , place. ty ( ) , span) ;
1982
1980
1983
- if let ( false , UpvarCapture :: ByValue ( .. ) ) = ( is_copy_type, curr_mode) {
1981
+ if let ( false , UpvarCapture :: ByValue ) = ( is_copy_type, curr_mode) {
1984
1982
for i in 0 ..place. projections . len ( ) {
1985
1983
match place. ty_before_projection ( i) . kind ( ) {
1986
1984
ty:: Adt ( def, _) if def. destructor ( fcx. tcx ) . is_some ( ) => {
@@ -2070,9 +2068,7 @@ fn adjust_for_move_closure<'tcx>(
2070
2068
truncate_place_to_len_and_update_capture_kind ( & mut place, & mut kind, idx) ;
2071
2069
}
2072
2070
2073
- // AMAN: I think we don't need the span inside the ByValue anymore
2074
- // we have more detailed span in CaptureInfo
2075
- ( place, ty:: UpvarCapture :: ByValue ( None ) )
2071
+ ( place, ty:: UpvarCapture :: ByValue )
2076
2072
}
2077
2073
2078
2074
/// Adjust closure capture just that if taking ownership of data, only move data
@@ -2085,7 +2081,7 @@ fn adjust_for_non_move_closure<'tcx>(
2085
2081
place. projections . iter ( ) . position ( |proj| proj. kind == ProjectionKind :: Deref ) ;
2086
2082
2087
2083
match kind {
2088
- ty:: UpvarCapture :: ByValue ( .. ) => {
2084
+ ty:: UpvarCapture :: ByValue => {
2089
2085
if let Some ( idx) = contains_deref {
2090
2086
truncate_place_to_len_and_update_capture_kind ( & mut place, & mut kind, idx) ;
2091
2087
}
@@ -2128,7 +2124,7 @@ fn construct_capture_kind_reason_string<'tcx>(
2128
2124
let place_str = construct_place_string ( tcx, place) ;
2129
2125
2130
2126
let capture_kind_str = match capture_info. capture_kind {
2131
- ty:: UpvarCapture :: ByValue ( _ ) => "ByValue" . into ( ) ,
2127
+ ty:: UpvarCapture :: ByValue => "ByValue" . into ( ) ,
2132
2128
ty:: UpvarCapture :: ByRef ( borrow) => format ! ( "{:?}" , borrow. kind) ,
2133
2129
} ;
2134
2130
@@ -2149,7 +2145,7 @@ fn construct_capture_info_string<'tcx>(
2149
2145
let place_str = construct_place_string ( tcx, place) ;
2150
2146
2151
2147
let capture_kind_str = match capture_info. capture_kind {
2152
- ty:: UpvarCapture :: ByValue ( _ ) => "ByValue" . into ( ) ,
2148
+ ty:: UpvarCapture :: ByValue => "ByValue" . into ( ) ,
2153
2149
ty:: UpvarCapture :: ByRef ( borrow) => format ! ( "{:?}" , borrow. kind) ,
2154
2150
} ;
2155
2151
format ! ( "{} -> {}" , place_str, capture_kind_str)
@@ -2240,18 +2236,11 @@ fn determine_capture_info<'tcx>(
2240
2236
// If the capture kind is equivalent then, we don't need to escalate and can compare the
2241
2237
// expressions.
2242
2238
let eq_capture_kind = match ( capture_info_a. capture_kind , capture_info_b. capture_kind ) {
2243
- ( ty:: UpvarCapture :: ByValue ( _) , ty:: UpvarCapture :: ByValue ( _) ) => {
2244
- // We don't need to worry about the spans being ignored here.
2245
- //
2246
- // The expr_id in capture_info corresponds to the span that is stored within
2247
- // ByValue(span) and therefore it gets handled with priortizing based on
2248
- // expressions below.
2249
- true
2250
- }
2239
+ ( ty:: UpvarCapture :: ByValue , ty:: UpvarCapture :: ByValue ) => true ,
2251
2240
( ty:: UpvarCapture :: ByRef ( ref_a) , ty:: UpvarCapture :: ByRef ( ref_b) ) => {
2252
2241
ref_a. kind == ref_b. kind
2253
2242
}
2254
- ( ty:: UpvarCapture :: ByValue ( _ ) , _) | ( ty:: UpvarCapture :: ByRef ( _) , _) => false ,
2243
+ ( ty:: UpvarCapture :: ByValue , _) | ( ty:: UpvarCapture :: ByRef ( _) , _) => false ,
2255
2244
} ;
2256
2245
2257
2246
if eq_capture_kind {
@@ -2263,8 +2252,8 @@ fn determine_capture_info<'tcx>(
2263
2252
// We select the CaptureKind which ranks higher based the following priority order:
2264
2253
// ByValue > MutBorrow > UniqueImmBorrow > ImmBorrow
2265
2254
match ( capture_info_a. capture_kind , capture_info_b. capture_kind ) {
2266
- ( ty:: UpvarCapture :: ByValue ( _ ) , _) => capture_info_a,
2267
- ( _, ty:: UpvarCapture :: ByValue ( _ ) ) => capture_info_b,
2255
+ ( ty:: UpvarCapture :: ByValue , _) => capture_info_a,
2256
+ ( _, ty:: UpvarCapture :: ByValue ) => capture_info_b,
2268
2257
( ty:: UpvarCapture :: ByRef ( ref_a) , ty:: UpvarCapture :: ByRef ( ref_b) ) => {
2269
2258
match ( ref_a. kind , ref_b. kind ) {
2270
2259
// Take LHS:
@@ -2319,7 +2308,7 @@ fn truncate_place_to_len_and_update_capture_kind<'tcx>(
2319
2308
}
2320
2309
2321
2310
ty:: UpvarCapture :: ByRef ( ..) => { }
2322
- ty:: UpvarCapture :: ByValue ( .. ) => { }
2311
+ ty:: UpvarCapture :: ByValue => { }
2323
2312
}
2324
2313
2325
2314
place. projections . truncate ( len) ;
0 commit comments