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)!: remove impl GetAddress for Function #7343

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
10 changes: 0 additions & 10 deletions crates/oxc_ast/src/ast_impl/js.rs
Original file line number Diff line number Diff line change
Expand Up @@ -1011,16 +1011,6 @@ impl<'a> Function<'a> {
}
}

// FIXME: This is a workaround for we can't get current address by `TraverseCtx`,
// we will remove this once we support `TraverseCtx::current_address`.
// See: <https://github.com/oxc-project/oxc/pull/6881#discussion_r1816560516>
impl GetAddress for Function<'_> {
#[inline]
fn address(&self) -> Address {
Address::from_ptr(self)
}
}

impl<'a> FormalParameters<'a> {
/// Number of parameters bound in this parameter list.
pub fn parameters_count(&self) -> usize {
Expand Down
7 changes: 4 additions & 3 deletions crates/oxc_transformer/src/jsx/refresh.rs
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,7 @@ use base64::prelude::{Engine, BASE64_STANDARD};
use rustc_hash::FxHashMap;
use sha1::{Digest, Sha1};

use oxc_allocator::{CloneIn, GetAddress, Vec as ArenaVec};
use oxc_allocator::{Address, CloneIn, GetAddress, Vec as ArenaVec};
use oxc_ast::{ast::*, match_expression, AstBuilder, NONE};
use oxc_semantic::{Reference, ReferenceFlags, ScopeFlags, ScopeId, SymbolFlags};
use oxc_span::{Atom, GetSpan, SPAN};
Expand Down Expand Up @@ -289,8 +289,9 @@ impl<'a, 'ctx> Traverse<'a> for ReactRefresh<'a, 'ctx> {
// which is a `Statement::ExportDefaultDeclaration`
Ancestor::ExportDefaultDeclarationDeclaration(decl) => decl.address(),
// Otherwise just a `function Foo() {}`
// which is a `Statement::FunctionDeclaration`
_ => func.address(),
// which is a `Statement::FunctionDeclaration`.
// `Function` is always stored in a `Box`, so has a stable memory address.
_ => Address::from_ptr(func),
};
self.ctx.statement_injector.insert_after(&address, statement);
}
Expand Down
Loading