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

This commit is contained in:
DonIsaac 2024-08-19 05:32:30 +00:00
parent a7750e3303
commit 96422b6489
3 changed files with 5 additions and 3 deletions

View file

@ -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,
}

View file

@ -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;
@ -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 }
}
@ -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 }
}

View file

@ -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,
}