Parse inline const expressions
This commit is contained in:
parent
3c4ad55082
commit
c3e8d7965c
10 changed files with 60 additions and 3 deletions
|
@ -1152,6 +1152,7 @@ impl Expr {
|
|||
match self.kind {
|
||||
ExprKind::Box(_) => ExprPrecedence::Box,
|
||||
ExprKind::Array(_) => ExprPrecedence::Array,
|
||||
ExprKind::ConstBlock(_) => ExprPrecedence::ConstBlock,
|
||||
ExprKind::Call(..) => ExprPrecedence::Call,
|
||||
ExprKind::MethodCall(..) => ExprPrecedence::MethodCall,
|
||||
ExprKind::Tup(_) => ExprPrecedence::Tup,
|
||||
|
@ -1207,6 +1208,8 @@ pub enum ExprKind {
|
|||
Box(P<Expr>),
|
||||
/// An array (`[a, b, c, d]`)
|
||||
Array(Vec<P<Expr>>),
|
||||
/// Allow anonymous constants from an inline `const` block
|
||||
ConstBlock(AnonConst),
|
||||
/// A function call
|
||||
///
|
||||
/// The first field resolves to the function itself,
|
||||
|
|
|
@ -1106,6 +1106,9 @@ pub fn noop_visit_expr<T: MutVisitor>(
|
|||
match kind {
|
||||
ExprKind::Box(expr) => vis.visit_expr(expr),
|
||||
ExprKind::Array(exprs) => visit_exprs(exprs, vis),
|
||||
ExprKind::ConstBlock(anon_const) => {
|
||||
vis.visit_anon_const(anon_const);
|
||||
}
|
||||
ExprKind::Repeat(expr, count) => {
|
||||
vis.visit_expr(expr);
|
||||
vis.visit_anon_const(count);
|
||||
|
|
|
@ -153,6 +153,7 @@ pub fn ident_can_begin_expr(name: Symbol, span: Span, is_raw: bool) -> bool {
|
|||
kw::Do,
|
||||
kw::Box,
|
||||
kw::Break,
|
||||
kw::Const,
|
||||
kw::Continue,
|
||||
kw::False,
|
||||
kw::For,
|
||||
|
|
|
@ -282,6 +282,7 @@ pub enum ExprPrecedence {
|
|||
ForLoop,
|
||||
Loop,
|
||||
Match,
|
||||
ConstBlock,
|
||||
Block,
|
||||
TryBlock,
|
||||
Struct,
|
||||
|
@ -346,6 +347,7 @@ impl ExprPrecedence {
|
|||
ExprPrecedence::ForLoop |
|
||||
ExprPrecedence::Loop |
|
||||
ExprPrecedence::Match |
|
||||
ExprPrecedence::ConstBlock |
|
||||
ExprPrecedence::Block |
|
||||
ExprPrecedence::TryBlock |
|
||||
ExprPrecedence::Async |
|
||||
|
|
|
@ -717,6 +717,7 @@ pub fn walk_expr<'a, V: Visitor<'a>>(visitor: &mut V, expression: &'a Expr) {
|
|||
ExprKind::Array(ref subexpressions) => {
|
||||
walk_list!(visitor, visit_expr, subexpressions);
|
||||
}
|
||||
ExprKind::ConstBlock(ref anon_const) => visitor.visit_anon_const(anon_const),
|
||||
ExprKind::Repeat(ref element, ref count) => {
|
||||
visitor.visit_expr(element);
|
||||
visitor.visit_anon_const(count)
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue