Validation · rust-lang/rust@442b9a9 (original) (raw)
`@@ -807,6 +807,25 @@ impl<'a, 'tcx> Visitor<'tcx> for TypeChecker<'a, 'tcx> {
`
807
807
`)
`
808
808
`}
`
809
809
`}
`
``
810
`+
ProjectionElem::UnwrapUnsafeBinder(unwrapped_ty) => {
`
``
811
`+
let binder_ty = place_ref.ty(&self.body.local_decls, self.tcx);
`
``
812
`+
let ty::UnsafeBinder(binder_ty) = *binder_ty.ty.kind() else {
`
``
813
`+
self.fail(
`
``
814
`+
location,
`
``
815
`+
format!("WrapUnsafeBinder does not produce a ty::UnsafeBinder"),
`
``
816
`+
);
`
``
817
`+
return;
`
``
818
`+
};
`
``
819
`+
let binder_inner_ty = self.tcx.instantiate_bound_regions_with_erased(*binder_ty);
`
``
820
`+
if !self.mir_assign_valid_types(unwrapped_ty, binder_inner_ty) {
`
``
821
`+
self.fail(
`
``
822
`+
location,
`
``
823
`+
format!(
`
``
824
`+
"Cannot unwrap unsafe binder {binder_ty:?} into type {unwrapped_ty:?}"
`
``
825
`+
),
`
``
826
`+
);
`
``
827
`+
}
`
``
828
`+
}
`
810
829
` _ => {}
`
811
830
`}
`
812
831
`self.super_projection_elem(place_ref, elem, context, location);
`
`@@ -1361,8 +1380,25 @@ impl<'a, 'tcx> Visitor<'tcx> for TypeChecker<'a, 'tcx> {
`
1361
1380
` | Rvalue::ThreadLocalRef(_)
`
1362
1381
` | Rvalue::RawPtr(_, _)
`
1363
1382
` | Rvalue::NullaryOp(NullOp::SizeOf | NullOp::AlignOf | NullOp::UbChecks, _)
`
1364
``
`-
| Rvalue::Discriminant(_)
`
1365
``
`-
| Rvalue::WrapUnsafeBinder(..) => {}
`
``
1383
`+
| Rvalue::Discriminant(_) => {}
`
``
1384
+
``
1385
`+
Rvalue::WrapUnsafeBinder(op, ty) => {
`
``
1386
`+
let unwrapped_ty = op.ty(self.body, self.tcx);
`
``
1387
`+
let ty::UnsafeBinder(binder_ty) = *ty.kind() else {
`
``
1388
`+
self.fail(
`
``
1389
`+
location,
`
``
1390
`+
format!("WrapUnsafeBinder does not produce a ty::UnsafeBinder"),
`
``
1391
`+
);
`
``
1392
`+
return;
`
``
1393
`+
};
`
``
1394
`+
let binder_inner_ty = self.tcx.instantiate_bound_regions_with_erased(*binder_ty);
`
``
1395
`+
if !self.mir_assign_valid_types(unwrapped_ty, binder_inner_ty) {
`
``
1396
`+
self.fail(
`
``
1397
`+
location,
`
``
1398
`+
format!("Cannot wrap {unwrapped_ty:?} into unsafe binder {binder_ty:?}"),
`
``
1399
`+
);
`
``
1400
`+
}
`
``
1401
`+
}
`
1366
1402
`}
`
1367
1403
`self.super_rvalue(rvalue, location);
`
1368
1404
`}
`