Skip to content

Commit 3a736e2

Browse files
Handle e2021 precise capturing of unsafe binder
1 parent 0fc6f16 commit 3a736e2

File tree

3 files changed

+9
-2
lines changed

3 files changed

+9
-2
lines changed

compiler/rustc_middle/src/ty/closure.rs

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -117,6 +117,10 @@ impl<'tcx> CapturedPlace<'tcx> {
117117
}
118118
},
119119

120+
HirProjectionKind::UnwrapUnsafeBinder => {
121+
write!(&mut symbol, "__unwrap").unwrap();
122+
}
123+
120124
// Ignore derefs for now, as they are likely caused by
121125
// autoderefs that don't appear in the original code.
122126
HirProjectionKind::Deref => {}

compiler/rustc_mir_build/src/builder/expr/as_place.rs

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -101,12 +101,12 @@ fn convert_to_hir_projections_and_truncate_for_capture(
101101
variant = Some(*idx);
102102
continue;
103103
}
104+
ProjectionElem::UnwrapUnsafeBinder(_) => HirProjectionKind::UnwrapUnsafeBinder,
104105
// These do not affect anything, they just make sure we know the right type.
105106
ProjectionElem::OpaqueCast(_) | ProjectionElem::Subtype(..) => continue,
106107
ProjectionElem::Index(..)
107108
| ProjectionElem::ConstantIndex { .. }
108-
| ProjectionElem::Subslice { .. }
109-
| ProjectionElem::UnwrapUnsafeBinder(_) => {
109+
| ProjectionElem::Subslice { .. } => {
110110
// We don't capture array-access projections.
111111
// We can stop here as arrays are captured completely.
112112
break;

tests/ui/unsafe-binders/cat-projection.rs

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,3 +1,6 @@
1+
//@ revisions: e2015 e2021
2+
//@[e2015] edition: 2015
3+
//@[e2021] edition: 2021
14
//@ check-pass
25

36
#![feature(unsafe_binders)]

0 commit comments

Comments
 (0)