-
-
Notifications
You must be signed in to change notification settings - Fork 495
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
feat(oxc_allocator): Add new method clone_in_with_semantic_ids
for CloneIn
trait
#8608
base: main
Are you sure you want to change the base?
Conversation
How to use the Graphite Merge QueueAdd either label to this PR to merge it via the merge queue:
You must have a Graphite account in order to use the merge queue. Sign up using this link. An organization admin has enabled the Graphite Merge Queue in this repository. Please do not merge from GitHub as this will restart CI on PRs being processed by the merge queue. |
crates/oxc_ast/src/ast/js.rs
Outdated
@@ -41,7 +41,6 @@ pub struct Program<'a> { | |||
pub directives: Vec<'a, Directive<'a>>, | |||
pub body: Vec<'a, Statement<'a>>, | |||
#[estree(skip)] | |||
#[clone_in(default)] |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
This is not right, should use cfg(attribete)
Can you provide some context and link your Rolldown prototype for other reviewers? |
OK, I will link it once the new poc is finished. |
I'm not quite sure what you're trying to achieve here, but this may be relevant: oxc-project/backlog#127
At present, it unsets all But if we go the other way (as in your PR), then it will have ID fields set, but they're likely to be the wrong IDs. So either way is wrong! See also: oxc-project/backlog#96 |
incremental build scenario, since we need to modify the ast after parsing, we clone |
Ah I see. If you clone both the AST and also the matching But I suggest we introduce a new trait for this use case
Note on naming: I suggest We need I assume you'll also need a way to get the capacity required for the allocator you're cloning into, so I've also added that in #8621. Please take a look and confirm that covers what you need. |
Actually maybe we don't need a new trait. We could just add a 2nd method to ...and document the pitfalls of using this method! @IWANABETHATGUY Are you comfortable enough with |
Thanks for your guiding, I will try it tomorrow. I am working on other thing today. |
091b93a
to
e5c451e
Compare
How to use the Graphite Merge QueueAdd either label to this PR to merge it via the merge queue:
You must have a Graphite account in order to use the merge queue. Sign up using this link. An organization admin has enabled the Graphite Merge Queue in this repository. Please do not merge from GitHub as this will restart CI on PRs being processed by the merge queue. This stack of pull requests is managed by Graphite. Learn more about stacking. |
73768c1
to
a519e6e
Compare
clone_in_with_semantic_ids
for CloneIn
trait
CodSpeed Performance ReportMerging #8608 will not alter performanceComparing Summary
|
crates/oxc_allocator/src/clone_in.rs
Outdated
/// Almost same as `clone_in`, but for some special type, it will also clone the semantic ids. | ||
#[inline] | ||
fn clone_in_with_semantic_ids(&self, allocator: &'new_alloc Allocator) -> Self::Cloned { | ||
self.clone_in(allocator) | ||
} |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Please expand this comment to explain why it's generally a bad idea to use this method.
@@ -60,52 +62,92 @@ fn derive_enum(def: &EnumDef) -> TokenStream { | |||
} | |||
}; | |||
|
|||
impl_clone_in(&ty_ident, def.has_lifetime, &alloc_ident, &body) | |||
impl_clone_in(&ty_ident, def.has_lifetime, &alloc_ident, &body, "e!()) |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
You will need a clone_in_with_semantic_ids
impl for most enums too. If you call clone_in_with_semantic_ids
on a &Program
you want it to be using clone_in_with_semantic_ids
all the way through the AST, not diverting to clone_in
as soon as it hits a Statement
.
Otherwise Program::clone_in_with_semantic_ids
will do exactly the same as Program::clone_in
- cloned AST won't have any IDs.
1dd4c8e
to
c479a19
Compare
7f1144f
to
bd3e390
Compare
bd3e390
to
ad3ef33
Compare
clone_in
the new method also clonesemantic
fields, this is used for scenario like caching ast and semantic data at the same time.