diff --git a/compiler/rustc_ast/src/ast.rs b/compiler/rustc_ast/src/ast.rs index 97e070958751a..d10b098b6b920 100644 --- a/compiler/rustc_ast/src/ast.rs +++ b/compiler/rustc_ast/src/ast.rs @@ -1532,6 +1532,9 @@ impl Expr { } } + ExprKind::InitBlock(..) => ExprPrecedence::Jump, + ExprKind::InitTail(..) => ExprPrecedence::Jump, + ExprKind::Break(_ /*label*/, value) | ExprKind::Ret(value) | ExprKind::Yield(YieldKind::Prefix(value)) @@ -1653,6 +1656,19 @@ pub struct Closure { pub fn_arg_span: Span, } +#[derive(Clone, Encodable, Decodable, Debug)] +pub struct InitBlock { + pub init_kw_span: Span, + pub expr: P, + pub fn_decl: P, +} + +#[derive(Clone, Encodable, Decodable, Debug)] +pub enum InitKind { + Free(P), + Array(ThinVec>), +} + /// Limit types of a range (inclusive or exclusive). #[derive(Copy, Clone, PartialEq, Encodable, Decodable, Debug, Walkable)] pub enum RangeLimits { @@ -1770,6 +1786,10 @@ pub enum ExprKind { Match(P, ThinVec, MatchKind), /// A closure (e.g., `move |a, b, c| a + b + c`). Closure(Box), + /// An `init` block + InitBlock(P), + /// An in-place initialization at the tail position of an `init` block + InitTail(P), /// A block (`'label: { ... }`). Block(P, Option