@@ -8,7 +8,7 @@ use rustc_ast::{
88} ;
99pub use rustc_ast:: {
1010 BinOp , BinOpKind , BindingMode , BorrowKind , ByRef , CaptureBy , ImplPolarity , IsAuto , Movability ,
11- Mutability , UnOp ,
11+ Mutability , UnOp , UnsafeBinderCastKind ,
1212} ;
1313use rustc_data_structures:: fingerprint:: Fingerprint ;
1414use rustc_data_structures:: sorted_map:: SortedMap ;
@@ -1747,9 +1747,10 @@ impl Expr<'_> {
17471747 ExprKind :: Struct ( ..) => ExprPrecedence :: Struct ,
17481748 ExprKind :: Repeat ( ..) => ExprPrecedence :: Repeat ,
17491749 ExprKind :: Yield ( ..) => ExprPrecedence :: Yield ,
1750- ExprKind :: Type ( ..) | ExprKind :: InlineAsm ( ..) | ExprKind :: OffsetOf ( ..) => {
1751- ExprPrecedence :: Mac
1752- }
1750+ ExprKind :: Type ( ..)
1751+ | ExprKind :: InlineAsm ( ..)
1752+ | ExprKind :: OffsetOf ( ..)
1753+ | ExprKind :: UnsafeBinderCast ( ..) => ExprPrecedence :: Mac ,
17531754 ExprKind :: Err ( _) => ExprPrecedence :: Err ,
17541755 }
17551756 }
@@ -1777,6 +1778,9 @@ impl Expr<'_> {
17771778 // https://github.com/rust-lang/rfcs/blob/master/text/0803-type-ascription.md#type-ascription-and-temporaries
17781779 ExprKind :: Type ( ref e, _) => e. is_place_expr ( allow_projections_from) ,
17791780
1781+ // Unsafe binder cast preserves place-ness of the sub-expression.
1782+ ExprKind :: UnsafeBinderCast ( _, e, _) => e. is_place_expr ( allow_projections_from) ,
1783+
17801784 ExprKind :: Unary ( UnOp :: Deref , _) => true ,
17811785
17821786 ExprKind :: Field ( ref base, _) | ExprKind :: Index ( ref base, _, _) => {
@@ -1858,7 +1862,8 @@ impl Expr<'_> {
18581862 | ExprKind :: Field ( base, _)
18591863 | ExprKind :: Index ( base, _, _)
18601864 | ExprKind :: AddrOf ( .., base)
1861- | ExprKind :: Cast ( base, _) => {
1865+ | ExprKind :: Cast ( base, _)
1866+ | ExprKind :: UnsafeBinderCast ( _, base, _) => {
18621867 // This isn't exactly true for `Index` and all `Unary`, but we are using this
18631868 // method exclusively for diagnostics and there's a *cultural* pressure against
18641869 // them being used only for its side-effects.
@@ -2115,6 +2120,10 @@ pub enum ExprKind<'hir> {
21152120 /// A suspension point for coroutines (i.e., `yield <expr>`).
21162121 Yield ( & ' hir Expr < ' hir > , YieldSource ) ,
21172122
2123+ /// Operators which can be used to interconvert `unsafe` binder types.
2124+ /// e.g. `unsafe<'a> &'a i32` <=> `&i32`.
2125+ UnsafeBinderCast ( UnsafeBinderCastKind , & ' hir Expr < ' hir > , Option < & ' hir Ty < ' hir > > ) ,
2126+
21182127 /// A placeholder for an expression that wasn't syntactically well formed in some way.
21192128 Err ( rustc_span:: ErrorGuaranteed ) ,
21202129}
0 commit comments