@@ -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 ;
@@ -1747,9 +1747,10 @@ impl Expr<'_> {
1747
1747
ExprKind :: Struct ( ..) => ExprPrecedence :: Struct ,
1748
1748
ExprKind :: Repeat ( ..) => ExprPrecedence :: Repeat ,
1749
1749
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 ,
1753
1754
ExprKind :: Err ( _) => ExprPrecedence :: Err ,
1754
1755
}
1755
1756
}
@@ -1777,6 +1778,9 @@ impl Expr<'_> {
1777
1778
// https://github.com/rust-lang/rfcs/blob/master/text/0803-type-ascription.md#type-ascription-and-temporaries
1778
1779
ExprKind :: Type ( ref e, _) => e. is_place_expr ( allow_projections_from) ,
1779
1780
1781
+ // Unsafe binder cast preserves place-ness of the sub-expression.
1782
+ ExprKind :: UnsafeBinderCast ( _, e, _) => e. is_place_expr ( allow_projections_from) ,
1783
+
1780
1784
ExprKind :: Unary ( UnOp :: Deref , _) => true ,
1781
1785
1782
1786
ExprKind :: Field ( ref base, _) | ExprKind :: Index ( ref base, _, _) => {
@@ -1858,7 +1862,8 @@ impl Expr<'_> {
1858
1862
| ExprKind :: Field ( base, _)
1859
1863
| ExprKind :: Index ( base, _, _)
1860
1864
| ExprKind :: AddrOf ( .., base)
1861
- | ExprKind :: Cast ( base, _) => {
1865
+ | ExprKind :: Cast ( base, _)
1866
+ | ExprKind :: UnsafeBinderCast ( _, base, _) => {
1862
1867
// This isn't exactly true for `Index` and all `Unary`, but we are using this
1863
1868
// method exclusively for diagnostics and there's a *cultural* pressure against
1864
1869
// them being used only for its side-effects.
@@ -2115,6 +2120,10 @@ pub enum ExprKind<'hir> {
2115
2120
/// A suspension point for coroutines (i.e., `yield <expr>`).
2116
2121
Yield ( & ' hir Expr < ' hir > , YieldSource ) ,
2117
2122
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
+
2118
2127
/// A placeholder for an expression that wasn't syntactically well formed in some way.
2119
2128
Err ( rustc_span:: ErrorGuaranteed ) ,
2120
2129
}
0 commit comments