Skip to content

Commit acd732a

Browse files
committed
don't capture trailing derefs
1 parent 015c6a2 commit acd732a

File tree

1 file changed

+5
-7
lines changed

1 file changed

+5
-7
lines changed

compiler/rustc_typeck/src/check/upvar.rs

Lines changed: 5 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -948,7 +948,7 @@ fn truncate_projections_for_capture<'tcx>(
948948
let mut first_index_projection = None;
949949
let mut first_deref_projection = None;
950950
let mut first_raw_ptr = None;
951-
//let mut last_field_projection = None;
951+
let mut last_field_projection = None;
952952

953953
for (i, proj) in place.projections.iter().enumerate() {
954954
if proj.ty.is_unsafe_ptr() {
@@ -968,7 +968,7 @@ fn truncate_projections_for_capture<'tcx>(
968968
first_deref_projection.get_or_insert(i);
969969
}
970970
ProjectionKind::Field(..) => {
971-
//last_field_projection = Some(i);
971+
last_field_projection = Some(i);
972972
}
973973
ProjectionKind::Subslice => {} // We never capture this
974974
}
@@ -990,11 +990,9 @@ fn truncate_projections_for_capture<'tcx>(
990990
ty::UpvarCapture::ByRef(..) => length,
991991
};
992992

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-
//}
993+
// Since we will only have Field and Deref projections at this point.
994+
// This will truncate trailing derefs.
995+
length = last_field_projection.map_or(length, |idx| cmp::min(length, idx + 1));
998996

999997
place.projections.truncate(length);
1000998

0 commit comments

Comments
 (0)