@@ -1382,6 +1382,7 @@ impl Expr {
1382
1382
| ExprKind :: Tup ( _)
1383
1383
| ExprKind :: Type ( ..)
1384
1384
| ExprKind :: Underscore
1385
+ | ExprKind :: UnsafeBinderCast ( ..)
1385
1386
| ExprKind :: While ( ..)
1386
1387
| ExprKind :: Err ( _)
1387
1388
| ExprKind :: Dummy => ExprPrecedence :: Unambiguous ,
@@ -1509,7 +1510,13 @@ pub enum ExprKind {
1509
1510
/// `'label: for await? pat in iter { block }`
1510
1511
///
1511
1512
/// This is desugared to a combination of `loop` and `match` expressions.
1512
- ForLoop { pat : P < Pat > , iter : P < Expr > , body : P < Block > , label : Option < Label > , kind : ForLoopKind } ,
1513
+ ForLoop {
1514
+ pat : P < Pat > ,
1515
+ iter : P < Expr > ,
1516
+ body : P < Block > ,
1517
+ label : Option < Label > ,
1518
+ kind : ForLoopKind ,
1519
+ } ,
1513
1520
/// Conditionless loop (can be exited with `break`, `continue`, or `return`).
1514
1521
///
1515
1522
/// `'label: loop { block }`
@@ -1614,6 +1621,8 @@ pub enum ExprKind {
1614
1621
/// A `format_args!()` expression.
1615
1622
FormatArgs ( P < FormatArgs > ) ,
1616
1623
1624
+ UnsafeBinderCast ( UnsafeBinderCastKind , P < Expr > , Option < P < Ty > > ) ,
1625
+
1617
1626
/// Placeholder for an expression that wasn't syntactically well formed in some way.
1618
1627
Err ( ErrorGuaranteed ) ,
1619
1628
@@ -1652,6 +1661,16 @@ impl GenBlockKind {
1652
1661
}
1653
1662
}
1654
1663
1664
+ /// Whether we're unwrapping or wrapping an unsafe binder
1665
+ #[ derive( Copy , Clone , Debug , PartialEq , Eq ) ]
1666
+ #[ derive( Encodable , Decodable , HashStable_Generic ) ]
1667
+ pub enum UnsafeBinderCastKind {
1668
+ // e.g. `&i32` -> `unsafe<'a> &'a i32`
1669
+ Wrap ,
1670
+ // e.g. `unsafe<'a> &'a i32` -> `&i32`
1671
+ Unwrap ,
1672
+ }
1673
+
1655
1674
/// The explicit `Self` type in a "qualified path". The actual
1656
1675
/// path, including the trait and the associated item, is stored
1657
1676
/// separately. `position` represents the index of the associated
@@ -2223,6 +2242,12 @@ pub struct BareFnTy {
2223
2242
pub decl_span : Span ,
2224
2243
}
2225
2244
2245
+ #[ derive( Clone , Encodable , Decodable , Debug ) ]
2246
+ pub struct UnsafeBinderTy {
2247
+ pub generic_params : ThinVec < GenericParam > ,
2248
+ pub inner_ty : P < Ty > ,
2249
+ }
2250
+
2226
2251
/// The various kinds of type recognized by the compiler.
2227
2252
//
2228
2253
// Adding a new variant? Please update `test_ty` in `tests/ui/macros/stringify.rs`.
@@ -2242,6 +2267,8 @@ pub enum TyKind {
2242
2267
PinnedRef ( Option < Lifetime > , MutTy ) ,
2243
2268
/// A bare function (e.g., `fn(usize) -> bool`).
2244
2269
BareFn ( P < BareFnTy > ) ,
2270
+ /// An unsafe existential lifetime binder (e.g., `unsafe<'a> &'a ()`).
2271
+ UnsafeBinder ( P < UnsafeBinderTy > ) ,
2245
2272
/// The never type (`!`).
2246
2273
Never ,
2247
2274
/// A tuple (`(A, B, C, D,...)`).
@@ -2877,7 +2904,7 @@ pub enum ModKind {
2877
2904
/// or with definition outlined to a separate file `mod foo;` and already loaded from it.
2878
2905
/// The inner span is from the first token past `{` to the last token until `}`,
2879
2906
/// or from the first to the last token in the loaded file.
2880
- Loaded ( ThinVec < P < Item > > , Inline , ModSpans ) ,
2907
+ Loaded ( ThinVec < P < Item > > , Inline , ModSpans , Result < ( ) , ErrorGuaranteed > ) ,
2881
2908
/// Module with definition outlined to a separate file `mod foo;` but not yet loaded from it.
2882
2909
Unloaded ,
2883
2910
}
0 commit comments