Skip to content

Reduce number of attrs for #[visited_node] used by AST codegen #4281

@overlookmotel

Description

@overlookmotel

Currently:

#[visited_node]
pub enum Expression<'a> {
    #[visit_args(flags = ScopeFlags::Function)]
    FunctionExpression(Box<'a, Function<'a>>),
    /* ... */
}

#[visited_node]
pub struct TryStatement<'a> {
    /* ... */
    #[visit_as(FinallyClause)]
    pub finalizer: Option<Box<'a, BlockStatement<'a>>>,
}

Could we reduce the number of "special" attrs by changing visit_args(...) / visit_as(...) to visit(args(...)) / visit(as(...))?

#[visited_node]
pub enum Expression<'a> {
    #[visit(args(flags = ScopeFlags::Function))]
    FunctionExpression(Box<'a, Function<'a>>),
    /* ... */
}

#[visited_node]
pub struct TryStatement<'a> {
    /* ... */
    #[visit(as(FinallyClause))]
    pub finalizer: Option<Box<'a, BlockStatement<'a>>>,
}

@rzvxa What do you think? Not a big deal, but I think it'd be neater. I suspect we may end up adding more attrs later on (it may be useful, for instance, to tag all TS-only fields #[typescript]) and it could get out of hand.

Metadata

Metadata

Assignees

Labels

A-astArea - ASTC-cleanupCategory - technical debt or refactoring. Solution not expected to change behavior

Type

No type

Priority

None yet

Projects

No projects

Milestone

No milestone

Relationships

None yet

Development

No branches or pull requests

Issue actions