@@ -284,6 +284,46 @@ impl<'a, 'b, 'tcx> Visitor<'tcx> for TypeVerifier<'a, 'b, 'tcx> {
284284 )
285285 . unwrap ( ) ;
286286 }
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+ } ,
287327 ProjectionElem :: Subtype ( _) => {
288328 bug ! ( "ProjectionElem::Subtype shouldn't exist in borrowck" )
289329 }
@@ -2413,7 +2453,8 @@ impl<'a, 'tcx> TypeChecker<'a, 'tcx> {
24132453 | ProjectionElem :: OpaqueCast ( ..)
24142454 | ProjectionElem :: Index ( ..)
24152455 | ProjectionElem :: ConstantIndex { .. }
2416- | ProjectionElem :: Subslice { .. } => {
2456+ | ProjectionElem :: Subslice { .. }
2457+ | ProjectionElem :: UnsafeBinderCast ( ..) => {
24172458 // other field access
24182459 }
24192460 ProjectionElem :: Subtype ( _) => {
0 commit comments