@@ -13,6 +13,7 @@ use hir::Expr;
1313use hir:: def:: DefKind ;
1414use hir:: pat_util:: EnumerateAndAdjustIterator as _;
1515use rustc_abi:: { FIRST_VARIANT , FieldIdx , VariantIdx } ;
16+ use rustc_ast:: UnsafeBinderCastKind ;
1617use rustc_data_structures:: fx:: FxIndexMap ;
1718use rustc_hir:: def:: { CtorOf , Res } ;
1819use rustc_hir:: def_id:: LocalDefId ;
@@ -1393,10 +1394,18 @@ impl<'tcx, Cx: TypeInformationCtxt<'tcx>, D: Delegate<'tcx>> ExprUseVisitor<'tcx
13931394 self . cat_res ( expr. hir_id , expr. span , expr_ty, res)
13941395 }
13951396
1396- // both type ascription and unsafe binder casts don't affect
1397- // the place-ness of the subexpression.
1397+ // type ascription doesn't affect the place-ness of the subexpression.
13981398 hir:: ExprKind :: Type ( e, _) => self . cat_expr ( e) ,
1399- hir:: ExprKind :: UnsafeBinderCast ( _, e, _) => self . cat_expr ( e) ,
1399+
1400+ hir:: ExprKind :: UnsafeBinderCast ( UnsafeBinderCastKind :: Unwrap , e, _) => {
1401+ let base = self . cat_expr ( e) ?;
1402+ Ok ( self . cat_projection (
1403+ expr. hir_id ,
1404+ base,
1405+ expr_ty,
1406+ ProjectionKind :: UnwrapUnsafeBinder ,
1407+ ) )
1408+ }
14001409
14011410 hir:: ExprKind :: AddrOf ( ..)
14021411 | hir:: ExprKind :: Call ( ..)
@@ -1427,6 +1436,7 @@ impl<'tcx, Cx: TypeInformationCtxt<'tcx>, D: Delegate<'tcx>> ExprUseVisitor<'tcx
14271436 | hir:: ExprKind :: Repeat ( ..)
14281437 | hir:: ExprKind :: InlineAsm ( ..)
14291438 | hir:: ExprKind :: OffsetOf ( ..)
1439+ | hir:: ExprKind :: UnsafeBinderCast ( UnsafeBinderCastKind :: Wrap , ..)
14301440 | hir:: ExprKind :: Err ( _) => Ok ( self . cat_rvalue ( expr. hir_id , expr_ty) ) ,
14311441 }
14321442 }
0 commit comments