@@ -1382,6 +1382,7 @@ impl Expr {
13821382 | ExprKind :: Tup ( _)
13831383 | ExprKind :: Type ( ..)
13841384 | ExprKind :: Underscore
1385+ | ExprKind :: UnsafeBinderCast ( ..)
13851386 | ExprKind :: While ( ..)
13861387 | ExprKind :: Err ( _)
13871388 | ExprKind :: Dummy => ExprPrecedence :: Unambiguous ,
@@ -1509,7 +1510,13 @@ pub enum ExprKind {
15091510 /// `'label: for await? pat in iter { block }`
15101511 ///
15111512 /// 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+ } ,
15131520 /// Conditionless loop (can be exited with `break`, `continue`, or `return`).
15141521 ///
15151522 /// `'label: loop { block }`
@@ -1614,6 +1621,8 @@ pub enum ExprKind {
16141621 /// A `format_args!()` expression.
16151622 FormatArgs ( P < FormatArgs > ) ,
16161623
1624+ UnsafeBinderCast ( UnsafeBinderCastKind , P < Expr > , Option < P < Ty > > ) ,
1625+
16171626 /// Placeholder for an expression that wasn't syntactically well formed in some way.
16181627 Err ( ErrorGuaranteed ) ,
16191628
@@ -1652,6 +1661,16 @@ impl GenBlockKind {
16521661 }
16531662}
16541663
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+
16551674/// The explicit `Self` type in a "qualified path". The actual
16561675/// path, including the trait and the associated item, is stored
16571676/// separately. `position` represents the index of the associated
@@ -2223,6 +2242,12 @@ pub struct BareFnTy {
22232242 pub decl_span : Span ,
22242243}
22252244
2245+ #[ derive( Clone , Encodable , Decodable , Debug ) ]
2246+ pub struct UnsafeBinderTy {
2247+ pub generic_params : ThinVec < GenericParam > ,
2248+ pub inner_ty : P < Ty > ,
2249+ }
2250+
22262251/// The various kinds of type recognized by the compiler.
22272252//
22282253// Adding a new variant? Please update `test_ty` in `tests/ui/macros/stringify.rs`.
@@ -2242,6 +2267,8 @@ pub enum TyKind {
22422267 PinnedRef ( Option < Lifetime > , MutTy ) ,
22432268 /// A bare function (e.g., `fn(usize) -> bool`).
22442269 BareFn ( P < BareFnTy > ) ,
2270+ /// An unsafe existential lifetime binder (e.g., `unsafe<'a> &'a ()`).
2271+ UnsafeBinder ( P < UnsafeBinderTy > ) ,
22452272 /// The never type (`!`).
22462273 Never ,
22472274 /// A tuple (`(A, B, C, D,...)`).
@@ -2877,7 +2904,7 @@ pub enum ModKind {
28772904 /// or with definition outlined to a separate file `mod foo;` and already loaded from it.
28782905 /// The inner span is from the first token past `{` to the last token until `}`,
28792906 /// 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 > ) ,
28812908 /// Module with definition outlined to a separate file `mod foo;` but not yet loaded from it.
28822909 Unloaded ,
28832910}
0 commit comments