@@ -385,7 +385,7 @@ impl<'a, 'tcx> FnCtxt<'a, 'tcx> {
385
385
base => bug ! ( "Expected upvar, found={:?}" , base) ,
386
386
} ;
387
387
388
- let place = truncate_projections_for_capture ( place, inferred_info . capture_clause ) ;
388
+ let place = truncate_projections_for_capture ( place, capture_info . capture_kind ) ;
389
389
390
390
let min_cap_list = match root_var_min_capture_list. get_mut ( & var_hir_id) {
391
391
None => {
@@ -933,7 +933,7 @@ impl<'a, 'tcx> euv::Delegate<'tcx> for InferBorrowKind<'a, 'tcx> {
933
933
/// - No Index projections are captured, since arrays are captured completely.
934
934
fn truncate_projections_for_capture < ' tcx > (
935
935
mut place : Place < ' tcx > ,
936
- capture_clause : hir :: CaptureBy ,
936
+ capture_kind : ty :: UpvarCapture < ' tcx > ,
937
937
) -> Place < ' tcx > {
938
938
if place. projections . is_empty ( ) {
939
939
// Nothing to do here
@@ -948,7 +948,7 @@ fn truncate_projections_for_capture<'tcx>(
948
948
let mut first_index_projection = None ;
949
949
let mut first_deref_projection = None ;
950
950
let mut first_raw_ptr = None ;
951
- let mut last_field_projection = None ;
951
+ // let mut last_field_projection = None;
952
952
953
953
for ( i, proj) in place. projections . iter ( ) . enumerate ( ) {
954
954
if proj. ty . is_unsafe_ptr ( ) {
@@ -968,7 +968,7 @@ fn truncate_projections_for_capture<'tcx>(
968
968
first_deref_projection. get_or_insert ( i) ;
969
969
}
970
970
ProjectionKind :: Field ( ..) => {
971
- last_field_projection = Some ( i) ;
971
+ // last_field_projection = Some(i);
972
972
}
973
973
ProjectionKind :: Subslice => { } // We never capture this
974
974
}
@@ -983,16 +983,18 @@ fn truncate_projections_for_capture<'tcx>(
983
983
length = first_index_projection. map_or ( length, |idx| cmp:: min ( length, idx) ) ;
984
984
985
985
// In case of move closure, don't apply Deref or any further projections
986
- length = match capture_clause {
987
- hir:: CaptureBy :: Value => first_deref_projection. map_or ( length, |idx| cmp:: min ( length, idx) ) ,
988
- hir:: CaptureBy :: Ref => length,
986
+ length = match capture_kind {
987
+ ty:: UpvarCapture :: ByValue ( ..) => {
988
+ first_deref_projection. map_or ( length, |idx| cmp:: min ( length, idx) )
989
+ }
990
+ ty:: UpvarCapture :: ByRef ( ..) => length,
989
991
} ;
990
992
991
- if env:: var ( "SG_DROP_DEREFS" ) . is_ok ( ) {
992
- // Since we will only have Field and Deref projections at this point.
993
- // This will truncate trailing derefs.
994
- length = last_field_projection. map_or ( length, |idx| cmp:: min ( length, idx + 1 ) ) ;
995
- }
993
+ // if env::var("SG_DROP_DEREFS").is_ok() {
994
+ // // Since we will only have Field and Deref projections at this point.
995
+ // // This will truncate trailing derefs.
996
+ // length = last_field_projection.map_or(length, |idx| cmp::min(length, idx + 1));
997
+ // }
996
998
997
999
place. projections . truncate ( length) ;
998
1000
0 commit comments