@@ -13,6 +13,7 @@ use hir::Expr;
13
13
use hir:: def:: DefKind ;
14
14
use hir:: pat_util:: EnumerateAndAdjustIterator as _;
15
15
use rustc_abi:: { FIRST_VARIANT , FieldIdx , VariantIdx } ;
16
+ use rustc_ast:: UnsafeBinderCastKind ;
16
17
use rustc_data_structures:: fx:: FxIndexMap ;
17
18
use rustc_hir:: def:: { CtorOf , Res } ;
18
19
use rustc_hir:: def_id:: LocalDefId ;
@@ -1393,10 +1394,18 @@ impl<'tcx, Cx: TypeInformationCtxt<'tcx>, D: Delegate<'tcx>> ExprUseVisitor<'tcx
1393
1394
self . cat_res ( expr. hir_id , expr. span , expr_ty, res)
1394
1395
}
1395
1396
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.
1398
1398
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
+ }
1400
1409
1401
1410
hir:: ExprKind :: AddrOf ( ..)
1402
1411
| hir:: ExprKind :: Call ( ..)
@@ -1427,6 +1436,7 @@ impl<'tcx, Cx: TypeInformationCtxt<'tcx>, D: Delegate<'tcx>> ExprUseVisitor<'tcx
1427
1436
| hir:: ExprKind :: Repeat ( ..)
1428
1437
| hir:: ExprKind :: InlineAsm ( ..)
1429
1438
| hir:: ExprKind :: OffsetOf ( ..)
1439
+ | hir:: ExprKind :: UnsafeBinderCast ( UnsafeBinderCastKind :: Wrap , ..)
1430
1440
| hir:: ExprKind :: Err ( _) => Ok ( self . cat_rvalue ( expr. hir_id , expr_ty) ) ,
1431
1441
}
1432
1442
}
0 commit comments