@@ -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 ;
@@ -1755,9 +1755,10 @@ impl Expr<'_> {
17551755 ExprKind :: Struct ( ..) => ExprPrecedence :: Struct ,
17561756 ExprKind :: Repeat ( ..) => ExprPrecedence :: Repeat ,
17571757 ExprKind :: Yield ( ..) => ExprPrecedence :: Yield ,
1758- ExprKind :: Type ( ..) | ExprKind :: InlineAsm ( ..) | ExprKind :: OffsetOf ( ..) => {
1759- ExprPrecedence :: Mac
1760- }
1758+ ExprKind :: Type ( ..)
1759+ | ExprKind :: InlineAsm ( ..)
1760+ | ExprKind :: OffsetOf ( ..)
1761+ | ExprKind :: UnsafeBinderCast ( ..) => ExprPrecedence :: Mac ,
17611762 ExprKind :: Err ( _) => ExprPrecedence :: Err ,
17621763 }
17631764 }
@@ -1785,6 +1786,9 @@ impl Expr<'_> {
17851786 // https://github.com/rust-lang/rfcs/blob/master/text/0803-type-ascription.md#type-ascription-and-temporaries
17861787 ExprKind :: Type ( ref e, _) => e. is_place_expr ( allow_projections_from) ,
17871788
1789+ // Unsafe binder cast preserves place-ness of the sub-expression.
1790+ ExprKind :: UnsafeBinderCast ( _, e, _) => e. is_place_expr ( allow_projections_from) ,
1791+
17881792 ExprKind :: Unary ( UnOp :: Deref , _) => true ,
17891793
17901794 ExprKind :: Field ( ref base, _) | ExprKind :: Index ( ref base, _, _) => {
@@ -1866,7 +1870,8 @@ impl Expr<'_> {
18661870 | ExprKind :: Field ( base, _)
18671871 | ExprKind :: Index ( base, _, _)
18681872 | ExprKind :: AddrOf ( .., base)
1869- | ExprKind :: Cast ( base, _) => {
1873+ | ExprKind :: Cast ( base, _)
1874+ | ExprKind :: UnsafeBinderCast ( _, base, _) => {
18701875 // This isn't exactly true for `Index` and all `Unary`, but we are using this
18711876 // method exclusively for diagnostics and there's a *cultural* pressure against
18721877 // them being used only for its side-effects.
@@ -2123,6 +2128,10 @@ pub enum ExprKind<'hir> {
21232128 /// A suspension point for coroutines (i.e., `yield <expr>`).
21242129 Yield ( & ' hir Expr < ' hir > , YieldSource ) ,
21252130
2131+ /// Operators which can be used to interconvert `unsafe` binder types.
2132+ /// e.g. `unsafe<'a> &'a i32` <=> `&i32`.
2133+ UnsafeBinderCast ( UnsafeBinderCastKind , & ' hir Expr < ' hir > , Option < & ' hir Ty < ' hir > > ) ,
2134+
21262135 /// A placeholder for an expression that wasn't syntactically well formed in some way.
21272136 Err ( rustc_span:: ErrorGuaranteed ) ,
21282137}
0 commit comments