Skip to content

Commit

Permalink
refactor(ast): make AstBuilder non-exhaustive (#4925)
Browse files Browse the repository at this point in the history
  • Loading branch information
DonIsaac committed Aug 19, 2024
1 parent a7750e3 commit 96422b6
Show file tree
Hide file tree
Showing 3 changed files with 5 additions and 3 deletions.
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

0 comments on commit 96422b6

Please sign in to comment.