Handle e2021 precise capturing of unsafe binder

This commit is contained in:
Michael Goulet 2025-05-28 12:17:18 +00:00
parent 0fc6f1672b
commit 3a736e2726
3 changed files with 9 additions and 2 deletions

View file

@ -117,6 +117,10 @@ impl<'tcx> CapturedPlace<'tcx> {
}
},
HirProjectionKind::UnwrapUnsafeBinder => {
write!(&mut symbol, "__unwrap").unwrap();
}
// Ignore derefs for now, as they are likely caused by
// autoderefs that don't appear in the original code.
HirProjectionKind::Deref => {}

View file

@ -101,12 +101,12 @@ fn convert_to_hir_projections_and_truncate_for_capture(
variant = Some(*idx);
continue;
}
ProjectionElem::UnwrapUnsafeBinder(_) => HirProjectionKind::UnwrapUnsafeBinder,
// These do not affect anything, they just make sure we know the right type.
ProjectionElem::OpaqueCast(_) | ProjectionElem::Subtype(..) => continue,
ProjectionElem::Index(..)
| ProjectionElem::ConstantIndex { .. }
| ProjectionElem::Subslice { .. }
| ProjectionElem::UnwrapUnsafeBinder(_) => {
| ProjectionElem::Subslice { .. } => {
// We don't capture array-access projections.
// We can stop here as arrays are captured completely.
break;

View file

@ -1,3 +1,6 @@
//@ revisions: e2015 e2021
//@[e2015] edition: 2015
//@[e2021] edition: 2021
//@ check-pass
#![feature(unsafe_binders)]