@@ -8,7 +8,7 @@ use rustc_ast::{
88} ;
99pub use rustc_ast:: {
1010 BinOp , BinOpKind , BindingMode , BorrowKind , BoundConstness , BoundPolarity , ByRef , CaptureBy ,
11- ImplPolarity , IsAuto , Movability , Mutability , UnOp ,
11+ ImplPolarity , IsAuto , Movability , Mutability , UnOp , UnsafeBinderCastKind ,
1212} ;
1313use rustc_data_structures:: fingerprint:: Fingerprint ;
1414use rustc_data_structures:: sorted_map:: SortedMap ;
@@ -1740,6 +1740,7 @@ impl Expr<'_> {
17401740 | ExprKind :: Struct ( ..)
17411741 | ExprKind :: Tup ( _)
17421742 | ExprKind :: Type ( ..)
1743+ | ExprKind :: UnsafeBinderCast ( ..)
17431744 | ExprKind :: Err ( _) => ExprPrecedence :: Unambiguous ,
17441745
17451746 ExprKind :: DropTemps ( ref expr, ..) => expr. precedence ( ) ,
@@ -1769,6 +1770,9 @@ impl Expr<'_> {
17691770 // https://github.com/rust-lang/rfcs/blob/master/text/0803-type-ascription.md#type-ascription-and-temporaries
17701771 ExprKind :: Type ( ref e, _) => e. is_place_expr ( allow_projections_from) ,
17711772
1773+ // Unsafe binder cast preserves place-ness of the sub-expression.
1774+ ExprKind :: UnsafeBinderCast ( _, e, _) => e. is_place_expr ( allow_projections_from) ,
1775+
17721776 ExprKind :: Unary ( UnOp :: Deref , _) => true ,
17731777
17741778 ExprKind :: Field ( ref base, _) | ExprKind :: Index ( ref base, _, _) => {
@@ -1850,7 +1854,8 @@ impl Expr<'_> {
18501854 | ExprKind :: Field ( base, _)
18511855 | ExprKind :: Index ( base, _, _)
18521856 | ExprKind :: AddrOf ( .., base)
1853- | ExprKind :: Cast ( base, _) => {
1857+ | ExprKind :: Cast ( base, _)
1858+ | ExprKind :: UnsafeBinderCast ( _, base, _) => {
18541859 // This isn't exactly true for `Index` and all `Unary`, but we are using this
18551860 // method exclusively for diagnostics and there's a *cultural* pressure against
18561861 // them being used only for its side-effects.
@@ -2144,6 +2149,10 @@ pub enum ExprKind<'hir> {
21442149 /// A suspension point for coroutines (i.e., `yield <expr>`).
21452150 Yield ( & ' hir Expr < ' hir > , YieldSource ) ,
21462151
2152+ /// Operators which can be used to interconvert `unsafe` binder types.
2153+ /// e.g. `unsafe<'a> &'a i32` <=> `&i32`.
2154+ UnsafeBinderCast ( UnsafeBinderCastKind , & ' hir Expr < ' hir > , Option < & ' hir Ty < ' hir > > ) ,
2155+
21472156 /// A placeholder for an expression that wasn't syntactically well formed in some way.
21482157 Err ( rustc_span:: ErrorGuaranteed ) ,
21492158}
0 commit comments