Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

refactor(ast): make AstBuilder non-exhaustive #4925

Merged
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
1 change: 1 addition & 0 deletions crates/oxc_ast/src/generated/ast_builder.rs
Original file line number Diff line number Diff line change
Expand Up @@ -14,6 +14,7 @@ use crate::ast::*;

/// AST builder for creating AST nodes
#[derive(Clone, Copy)]
#[non_exhaustive]
pub struct AstBuilder<'a> {
pub allocator: &'a Allocator,
}
Expand Down
6 changes: 3 additions & 3 deletions crates/oxc_transformer/src/lib.rs
Original file line number Diff line number Diff line change
Expand Up @@ -34,7 +34,7 @@ use es2019::ES2019;
use es2020::ES2020;
use es2021::ES2021;
use oxc_allocator::{Allocator, Vec};
use oxc_ast::{ast::*, AstBuilder, Trivias};
use oxc_ast::{ast::*, Trivias};
use oxc_diagnostics::OxcDiagnostic;
use oxc_semantic::{ScopeTree, SemanticBuilder, SymbolTable};
use oxc_span::SourceType;
Expand Down Expand Up @@ -107,7 +107,7 @@ impl<'a> Transformer<'a> {
.build(program)
.semantic
.into_symbol_table_and_scope_tree();
let TransformCtx { ast: AstBuilder { allocator }, .. } = *self.ctx;
let allocator: &'a Allocator = self.ctx.ast.allocator;
let (symbols, scopes) = traverse_mut(&mut self, allocator, program, symbols, scopes);
TransformerReturn { errors: self.ctx.take_errors(), symbols, scopes }
}
Expand All @@ -118,7 +118,7 @@ impl<'a> Transformer<'a> {
scopes: ScopeTree,
program: &mut Program<'a>,
) -> TransformerReturn {
let TransformCtx { ast: AstBuilder { allocator }, .. } = *self.ctx;
let allocator: &'a Allocator = self.ctx.ast.allocator;
let (symbols, scopes) = traverse_mut(&mut self, allocator, program, symbols, scopes);
TransformerReturn { errors: self.ctx.take_errors(), symbols, scopes }
}
Expand Down
1 change: 1 addition & 0 deletions tasks/ast_tools/src/generators/ast_builder.rs
Original file line number Diff line number Diff line change
Expand Up @@ -57,6 +57,7 @@ impl Generator for AstBuilderGenerator {
///@@line_break
/// AST builder for creating AST nodes
#[derive(Clone, Copy)]
#[non_exhaustive]
pub struct AstBuilder<'a> {
pub allocator: &'a Allocator,
}
Expand Down