@@ -302,6 +302,25 @@ impl<'a, 'b, 'tcx> Visitor<'tcx> for TypeVerifier<'a, 'b, 'tcx> {
302
302
)
303
303
. unwrap ( ) ;
304
304
}
305
+ ProjectionElem :: UnwrapUnsafeBinder ( ty) => {
306
+ let ty:: UnsafeBinder ( binder_ty) = * base_ty. ty . kind ( ) else {
307
+ unreachable ! ( ) ;
308
+ } ;
309
+ let found_ty = self . typeck . infcx . instantiate_binder_with_fresh_vars (
310
+ self . body ( ) . source_info ( location) . span ,
311
+ BoundRegionConversionTime :: HigherRankedType ,
312
+ binder_ty. into ( ) ,
313
+ ) ;
314
+ self . typeck
315
+ . relate_types (
316
+ ty,
317
+ context. ambient_variance ( ) ,
318
+ found_ty,
319
+ location. to_locations ( ) ,
320
+ ConstraintCategory :: Boring ,
321
+ )
322
+ . unwrap ( ) ;
323
+ }
305
324
ProjectionElem :: Subtype ( _) => {
306
325
bug ! ( "ProjectionElem::Subtype shouldn't exist in borrowck" )
307
326
}
@@ -2233,6 +2252,27 @@ impl<'a, 'tcx> TypeChecker<'a, 'tcx> {
2233
2252
self . check_operand ( right, location) ;
2234
2253
}
2235
2254
2255
+ Rvalue :: WrapUnsafeBinder ( op, ty) => {
2256
+ self . check_operand ( op, location) ;
2257
+ let operand_ty = op. ty ( self . body , self . tcx ( ) ) ;
2258
+
2259
+ let ty:: UnsafeBinder ( binder_ty) = * ty. kind ( ) else {
2260
+ unreachable ! ( ) ;
2261
+ } ;
2262
+ let expected_ty = self . infcx . instantiate_binder_with_fresh_vars (
2263
+ self . body ( ) . source_info ( location) . span ,
2264
+ BoundRegionConversionTime :: HigherRankedType ,
2265
+ binder_ty. into ( ) ,
2266
+ ) ;
2267
+ self . sub_types (
2268
+ operand_ty,
2269
+ expected_ty,
2270
+ location. to_locations ( ) ,
2271
+ ConstraintCategory :: Boring ,
2272
+ )
2273
+ . unwrap ( ) ;
2274
+ }
2275
+
2236
2276
Rvalue :: RawPtr ( ..)
2237
2277
| Rvalue :: ThreadLocalRef ( ..)
2238
2278
| Rvalue :: Len ( ..)
@@ -2258,7 +2298,8 @@ impl<'a, 'tcx> TypeChecker<'a, 'tcx> {
2258
2298
| Rvalue :: NullaryOp ( ..)
2259
2299
| Rvalue :: CopyForDeref ( ..)
2260
2300
| Rvalue :: UnaryOp ( ..)
2261
- | Rvalue :: Discriminant ( ..) => None ,
2301
+ | Rvalue :: Discriminant ( ..)
2302
+ | Rvalue :: WrapUnsafeBinder ( ..) => None ,
2262
2303
2263
2304
Rvalue :: Aggregate ( aggregate, _) => match * * aggregate {
2264
2305
AggregateKind :: Adt ( _, _, _, user_ty, _) => user_ty,
@@ -2450,7 +2491,8 @@ impl<'a, 'tcx> TypeChecker<'a, 'tcx> {
2450
2491
| ProjectionElem :: OpaqueCast ( ..)
2451
2492
| ProjectionElem :: Index ( ..)
2452
2493
| ProjectionElem :: ConstantIndex { .. }
2453
- | ProjectionElem :: Subslice { .. } => {
2494
+ | ProjectionElem :: Subslice { .. }
2495
+ | ProjectionElem :: UnwrapUnsafeBinder ( _) => {
2454
2496
// other field access
2455
2497
}
2456
2498
ProjectionElem :: Subtype ( _) => {
0 commit comments