@@ -8,7 +8,7 @@ use rustc_ast::{
8
8
} ;
9
9
pub use rustc_ast:: {
10
10
BinOp , BinOpKind , BindingMode , BorrowKind , ByRef , CaptureBy , ImplPolarity , IsAuto , Movability ,
11
- Mutability , UnOp ,
11
+ Mutability , UnOp , UnsafeBinderCastKind ,
12
12
} ;
13
13
use rustc_data_structures:: fingerprint:: Fingerprint ;
14
14
use rustc_data_structures:: sorted_map:: SortedMap ;
@@ -1755,9 +1755,10 @@ impl Expr<'_> {
1755
1755
ExprKind :: Struct ( ..) => ExprPrecedence :: Struct ,
1756
1756
ExprKind :: Repeat ( ..) => ExprPrecedence :: Repeat ,
1757
1757
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 ,
1761
1762
ExprKind :: Err ( _) => ExprPrecedence :: Err ,
1762
1763
}
1763
1764
}
@@ -1785,6 +1786,9 @@ impl Expr<'_> {
1785
1786
// https://github.com/rust-lang/rfcs/blob/master/text/0803-type-ascription.md#type-ascription-and-temporaries
1786
1787
ExprKind :: Type ( ref e, _) => e. is_place_expr ( allow_projections_from) ,
1787
1788
1789
+ // Unsafe binder cast preserves place-ness of the sub-expression.
1790
+ ExprKind :: UnsafeBinderCast ( _, e, _) => e. is_place_expr ( allow_projections_from) ,
1791
+
1788
1792
ExprKind :: Unary ( UnOp :: Deref , _) => true ,
1789
1793
1790
1794
ExprKind :: Field ( ref base, _) | ExprKind :: Index ( ref base, _, _) => {
@@ -1866,7 +1870,8 @@ impl Expr<'_> {
1866
1870
| ExprKind :: Field ( base, _)
1867
1871
| ExprKind :: Index ( base, _, _)
1868
1872
| ExprKind :: AddrOf ( .., base)
1869
- | ExprKind :: Cast ( base, _) => {
1873
+ | ExprKind :: Cast ( base, _)
1874
+ | ExprKind :: UnsafeBinderCast ( _, base, _) => {
1870
1875
// This isn't exactly true for `Index` and all `Unary`, but we are using this
1871
1876
// method exclusively for diagnostics and there's a *cultural* pressure against
1872
1877
// them being used only for its side-effects.
@@ -2123,6 +2128,10 @@ pub enum ExprKind<'hir> {
2123
2128
/// A suspension point for coroutines (i.e., `yield <expr>`).
2124
2129
Yield ( & ' hir Expr < ' hir > , YieldSource ) ,
2125
2130
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
+
2126
2135
/// A placeholder for an expression that wasn't syntactically well formed in some way.
2127
2136
Err ( rustc_span:: ErrorGuaranteed ) ,
2128
2137
}
0 commit comments