@@ -409,7 +409,7 @@ impl<'a, 'tcx> FnCtxt<'a, 'tcx> {
409409 } ;
410410
411411 let updated = match capture_info. capture_kind {
412- ty:: UpvarCapture :: ByValue ( .. ) => match closure_kind {
412+ ty:: UpvarCapture :: ByValue => match closure_kind {
413413 ty:: ClosureKind :: Fn | ty:: ClosureKind :: FnMut => {
414414 ( ty:: ClosureKind :: FnOnce , Some ( ( usage_span, place. clone ( ) ) ) )
415415 }
@@ -1086,7 +1086,7 @@ impl<'a, 'tcx> FnCtxt<'a, 'tcx> {
10861086 for captured_place in root_var_min_capture_list. iter ( ) {
10871087 match captured_place. info . capture_kind {
10881088 // Only care about captures that are moved into the closure
1089- ty:: UpvarCapture :: ByValue ( .. ) => {
1089+ ty:: UpvarCapture :: ByValue => {
10901090 projections_list. push ( captured_place. place . projections . as_slice ( ) ) ;
10911091 diagnostics_info. insert ( UpvarMigrationInfo :: CapturingPrecise {
10921092 source_expr : captured_place. info . path_expr_id ,
@@ -1481,7 +1481,7 @@ impl<'a, 'tcx> FnCtxt<'a, 'tcx> {
14811481 // at the first Deref in `adjust_upvar_borrow_kind_for_consume` and then moved into
14821482 // the closure.
14831483 hir:: CaptureBy :: Value if !place. deref_tys ( ) . any ( ty:: TyS :: is_ref) => {
1484- ty:: UpvarCapture :: ByValue ( None )
1484+ ty:: UpvarCapture :: ByValue
14851485 }
14861486 hir:: CaptureBy :: Value | hir:: CaptureBy :: Ref => {
14871487 let origin = UpvarRegion ( upvar_id, closure_span) ;
@@ -1678,7 +1678,7 @@ fn apply_capture_kind_on_capture_ty<'tcx>(
16781678 capture_kind : UpvarCapture < ' tcx > ,
16791679) -> Ty < ' tcx > {
16801680 match capture_kind {
1681- ty:: UpvarCapture :: ByValue ( _ ) => ty,
1681+ ty:: UpvarCapture :: ByValue => ty,
16821682 ty:: UpvarCapture :: ByRef ( borrow) => tcx
16831683 . mk_ref ( borrow. region , ty:: TypeAndMut { ty : ty, mutbl : borrow. kind . to_mutbl_lossy ( ) } ) ,
16841684 }
@@ -1756,12 +1756,10 @@ impl<'a, 'tcx> InferBorrowKind<'a, 'tcx> {
17561756
17571757 debug ! ( ?upvar_id) ;
17581758
1759- let usage_span = tcx. hir ( ) . span ( diag_expr_id) ;
1760-
17611759 let capture_info = ty:: CaptureInfo {
17621760 capture_kind_expr_id : Some ( diag_expr_id) ,
17631761 path_expr_id : Some ( diag_expr_id) ,
1764- capture_kind : ty:: UpvarCapture :: ByValue ( Some ( usage_span ) ) ,
1762+ capture_kind : ty:: UpvarCapture :: ByValue ,
17651763 } ;
17661764
17671765 let curr_info = self . capture_information [ & place_with_id. place ] ;
@@ -1841,7 +1839,7 @@ impl<'a, 'tcx> InferBorrowKind<'a, 'tcx> {
18411839
18421840 debug ! ( ?curr_capture_info) ;
18431841
1844- if let ty:: UpvarCapture :: ByValue ( _ ) = curr_capture_info. capture_kind {
1842+ if let ty:: UpvarCapture :: ByValue = curr_capture_info. capture_kind {
18451843 // It's already captured by value, we don't need to do anything here
18461844 return ;
18471845 } 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> {
19611959 } ,
19621960
19631961 // Just truncating the place will never cause capture kind to be updated to ByValue
1964- ty:: UpvarCapture :: ByValue ( .. ) => unreachable ! ( ) ,
1962+ ty:: UpvarCapture :: ByValue => unreachable ! ( ) ,
19651963 }
19661964 }
19671965
@@ -1980,7 +1978,7 @@ fn restrict_precision_for_drop_types<'a, 'tcx>(
19801978) -> ( Place < ' tcx > , ty:: UpvarCapture < ' tcx > ) {
19811979 let is_copy_type = fcx. infcx . type_is_copy_modulo_regions ( fcx. param_env , place. ty ( ) , span) ;
19821980
1983- if let ( false , UpvarCapture :: ByValue ( .. ) ) = ( is_copy_type, curr_mode) {
1981+ if let ( false , UpvarCapture :: ByValue ) = ( is_copy_type, curr_mode) {
19841982 for i in 0 ..place. projections . len ( ) {
19851983 match place. ty_before_projection ( i) . kind ( ) {
19861984 ty:: Adt ( def, _) if def. destructor ( fcx. tcx ) . is_some ( ) => {
@@ -2070,9 +2068,7 @@ fn adjust_for_move_closure<'tcx>(
20702068 truncate_place_to_len_and_update_capture_kind ( & mut place, & mut kind, idx) ;
20712069 }
20722070
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 )
20762072}
20772073
20782074/// Adjust closure capture just that if taking ownership of data, only move data
@@ -2085,7 +2081,7 @@ fn adjust_for_non_move_closure<'tcx>(
20852081 place. projections . iter ( ) . position ( |proj| proj. kind == ProjectionKind :: Deref ) ;
20862082
20872083 match kind {
2088- ty:: UpvarCapture :: ByValue ( .. ) => {
2084+ ty:: UpvarCapture :: ByValue => {
20892085 if let Some ( idx) = contains_deref {
20902086 truncate_place_to_len_and_update_capture_kind ( & mut place, & mut kind, idx) ;
20912087 }
@@ -2128,7 +2124,7 @@ fn construct_capture_kind_reason_string<'tcx>(
21282124 let place_str = construct_place_string ( tcx, place) ;
21292125
21302126 let capture_kind_str = match capture_info. capture_kind {
2131- ty:: UpvarCapture :: ByValue ( _ ) => "ByValue" . into ( ) ,
2127+ ty:: UpvarCapture :: ByValue => "ByValue" . into ( ) ,
21322128 ty:: UpvarCapture :: ByRef ( borrow) => format ! ( "{:?}" , borrow. kind) ,
21332129 } ;
21342130
@@ -2149,7 +2145,7 @@ fn construct_capture_info_string<'tcx>(
21492145 let place_str = construct_place_string ( tcx, place) ;
21502146
21512147 let capture_kind_str = match capture_info. capture_kind {
2152- ty:: UpvarCapture :: ByValue ( _ ) => "ByValue" . into ( ) ,
2148+ ty:: UpvarCapture :: ByValue => "ByValue" . into ( ) ,
21532149 ty:: UpvarCapture :: ByRef ( borrow) => format ! ( "{:?}" , borrow. kind) ,
21542150 } ;
21552151 format ! ( "{} -> {}" , place_str, capture_kind_str)
@@ -2240,18 +2236,11 @@ fn determine_capture_info<'tcx>(
22402236 // If the capture kind is equivalent then, we don't need to escalate and can compare the
22412237 // expressions.
22422238 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 ,
22512240 ( ty:: UpvarCapture :: ByRef ( ref_a) , ty:: UpvarCapture :: ByRef ( ref_b) ) => {
22522241 ref_a. kind == ref_b. kind
22532242 }
2254- ( ty:: UpvarCapture :: ByValue ( _ ) , _) | ( ty:: UpvarCapture :: ByRef ( _) , _) => false ,
2243+ ( ty:: UpvarCapture :: ByValue , _) | ( ty:: UpvarCapture :: ByRef ( _) , _) => false ,
22552244 } ;
22562245
22572246 if eq_capture_kind {
@@ -2263,8 +2252,8 @@ fn determine_capture_info<'tcx>(
22632252 // We select the CaptureKind which ranks higher based the following priority order:
22642253 // ByValue > MutBorrow > UniqueImmBorrow > ImmBorrow
22652254 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,
22682257 ( ty:: UpvarCapture :: ByRef ( ref_a) , ty:: UpvarCapture :: ByRef ( ref_b) ) => {
22692258 match ( ref_a. kind , ref_b. kind ) {
22702259 // Take LHS:
@@ -2319,7 +2308,7 @@ fn truncate_place_to_len_and_update_capture_kind<'tcx>(
23192308 }
23202309
23212310 ty:: UpvarCapture :: ByRef ( ..) => { }
2322- ty:: UpvarCapture :: ByValue ( .. ) => { }
2311+ ty:: UpvarCapture :: ByValue => { }
23232312 }
23242313
23252314 place. projections . truncate ( len) ;
0 commit comments