@@ -302,6 +302,25 @@ impl<'a, 'b, 'tcx> Visitor<'tcx> for TypeVerifier<'a, 'b, 'tcx> {
302302                    ) 
303303                    . unwrap ( ) ; 
304304            } 
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+             } 
305324            ProjectionElem :: Subtype ( _)  => { 
306325                bug ! ( "ProjectionElem::Subtype shouldn't exist in borrowck" ) 
307326            } 
@@ -2233,6 +2252,27 @@ impl<'a, 'tcx> TypeChecker<'a, 'tcx> {
22332252                self . check_operand ( right,  location) ; 
22342253            } 
22352254
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+ 
22362276            Rvalue :: RawPtr ( ..) 
22372277            | Rvalue :: ThreadLocalRef ( ..) 
22382278            | Rvalue :: Len ( ..) 
@@ -2258,7 +2298,8 @@ impl<'a, 'tcx> TypeChecker<'a, 'tcx> {
22582298            | Rvalue :: NullaryOp ( ..) 
22592299            | Rvalue :: CopyForDeref ( ..) 
22602300            | Rvalue :: UnaryOp ( ..) 
2261-             | Rvalue :: Discriminant ( ..)  => None , 
2301+             | Rvalue :: Discriminant ( ..) 
2302+             | Rvalue :: WrapUnsafeBinder ( ..)  => None , 
22622303
22632304            Rvalue :: Aggregate ( aggregate,  _)  => match  * * aggregate { 
22642305                AggregateKind :: Adt ( _,  _,  _,  user_ty,  _)  => user_ty, 
@@ -2450,7 +2491,8 @@ impl<'a, 'tcx> TypeChecker<'a, 'tcx> {
24502491                | ProjectionElem :: OpaqueCast ( ..) 
24512492                | ProjectionElem :: Index ( ..) 
24522493                | ProjectionElem :: ConstantIndex  {  .. } 
2453-                 | ProjectionElem :: Subslice  {  .. }  => { 
2494+                 | ProjectionElem :: Subslice  {  .. } 
2495+                 | ProjectionElem :: UnwrapUnsafeBinder ( _)  => { 
24542496                    // other field access 
24552497                } 
24562498                ProjectionElem :: Subtype ( _)  => { 
0 commit comments