diff --git a/compiler/rustc_ast/src/ast.rs b/compiler/rustc_ast/src/ast.rs index 491a9bbda79b1..dd7f2e44f98f7 100644 --- a/compiler/rustc_ast/src/ast.rs +++ b/compiler/rustc_ast/src/ast.rs @@ -1474,6 +1474,9 @@ impl Expr { } } + ExprKind::InitBlock(..) => ExprPrecedence::Jump, + ExprKind::InitTail(..) => ExprPrecedence::Jump, + ExprKind::Break(_ /*label*/, value) | ExprKind::Ret(value) | ExprKind::Yield(YieldKind::Prefix(value)) @@ -1595,6 +1598,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)] pub enum RangeLimits { @@ -1712,6 +1728,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