@@ -284,6 +284,46 @@ impl<'a, 'b, 'tcx> Visitor<'tcx> for TypeVerifier<'a, 'b, 'tcx> {
284
284
)
285
285
. unwrap ( ) ;
286
286
}
287
+ ProjectionElem :: UnsafeBinderCast ( kind, ty) => match kind {
288
+ hir:: UnsafeBinderCastKind :: Wrap => {
289
+ let ty:: UnsafeBinder ( binder_ty) = * ty. kind ( ) else {
290
+ unreachable ! ( ) ;
291
+ } ;
292
+ let expected_ty = self . typeck . infcx . instantiate_binder_with_fresh_vars (
293
+ self . body ( ) . source_info ( location) . span ,
294
+ BoundRegionConversionTime :: HigherRankedType ,
295
+ binder_ty. into ( ) ,
296
+ ) ;
297
+ self . typeck
298
+ . relate_types (
299
+ expected_ty,
300
+ context. ambient_variance ( ) ,
301
+ base_ty. ty ,
302
+ location. to_locations ( ) ,
303
+ ConstraintCategory :: TypeAnnotation ,
304
+ )
305
+ . unwrap ( ) ;
306
+ }
307
+ hir:: UnsafeBinderCastKind :: Unwrap => {
308
+ let ty:: UnsafeBinder ( binder_ty) = * base_ty. ty . kind ( ) else {
309
+ unreachable ! ( ) ;
310
+ } ;
311
+ let found_ty = self . typeck . infcx . instantiate_binder_with_fresh_vars (
312
+ self . body ( ) . source_info ( location) . span ,
313
+ BoundRegionConversionTime :: HigherRankedType ,
314
+ binder_ty. into ( ) ,
315
+ ) ;
316
+ self . typeck
317
+ . relate_types (
318
+ ty,
319
+ context. ambient_variance ( ) ,
320
+ found_ty,
321
+ location. to_locations ( ) ,
322
+ ConstraintCategory :: TypeAnnotation ,
323
+ )
324
+ . unwrap ( ) ;
325
+ }
326
+ } ,
287
327
ProjectionElem :: Subtype ( _) => {
288
328
bug ! ( "ProjectionElem::Subtype shouldn't exist in borrowck" )
289
329
}
@@ -2413,7 +2453,8 @@ impl<'a, 'tcx> TypeChecker<'a, 'tcx> {
2413
2453
| ProjectionElem :: OpaqueCast ( ..)
2414
2454
| ProjectionElem :: Index ( ..)
2415
2455
| ProjectionElem :: ConstantIndex { .. }
2416
- | ProjectionElem :: Subslice { .. } => {
2456
+ | ProjectionElem :: Subslice { .. }
2457
+ | ProjectionElem :: UnsafeBinderCast ( ..) => {
2417
2458
// other field access
2418
2459
}
2419
2460
ProjectionElem :: Subtype ( _) => {
0 commit comments