feat(ast_tools): allow defining foreign types with #[ast(foreign = ...)]#8866
Merged
graphite-app[bot] merged 1 commit intomainfrom Feb 4, 2025
Conversation
This was referenced Feb 3, 2025
Member
Author
This was referenced Feb 3, 2025
a9d48f2 to
3fd392f
Compare
bd2f2e1 to
482836b
Compare
This was referenced Feb 3, 2025
3fd392f to
c5841cf
Compare
482836b to
dc0a998
Compare
This was referenced Feb 3, 2025
c5841cf to
7b2a5a2
Compare
dc0a998 to
534c4f8
Compare
Contributor
Merge activity
|
…..)]` (#8866) Allow informing `oxc_ast_tools` about foreign types in AST (e.g. `NonMaxU32`) and other types which it otherwise can't parse (e.g. `RegExpFlags`, which is generated by `bitflags!` macro). Mechanism is `#[ast(foreign = ...)]` attr on another type which acts as a "stand-in" for the real one, similar to `serde`'s [remote derive feature](https://serde.rs/remote-derive.html). ```rs bitflags! { pub struct RegExpFlags: u8 { /* ... */ } } /// This dummy type tells `oxc_ast_tools` about `RegExpFlags` #[ast(foreign = RegExpFlags)] struct RegExpFlagsAlias(u8); ```
7b2a5a2 to
440a439
Compare
534c4f8 to
9072f4c
Compare
graphite-app bot
pushed a commit
that referenced
this pull request
Feb 4, 2025
Add `#[ast]` attr to `ScopeId`, `SymbolId` and `ReferenceId` types. This makes them an "official" part of the AST, and removes the hacky "special case" logic from `oxc_ast_tools` which was previously working around that they weren't registered as part of the AST. This uses the `#[ast(foreign = ...)]` feature introduced in #8866 to inform `oxc_ast_tools` about the foreign `NonMaxU32` type, enabling the ID types to be parsed and understood.
Base automatically changed from
02-03-feat_ast_tools_support_nonzero_primitives
to
main
February 4, 2025 03:14
This was referenced Feb 4, 2025
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.

Allow informing
oxc_ast_toolsabout foreign types in AST (e.g.NonMaxU32) and other types which it otherwise can't parse (e.g.RegExpFlags, which is generated bybitflags!macro).Mechanism is
#[ast(foreign = ...)]attr on another type which acts as a "stand-in" for the real one, similar toserde's remote derive feature.