refactor(parser): Token::set_* method visible only within lexer#19852
Merged
graphite-app[bot] merged 1 commit intomainfrom Feb 28, 2026
Merged
Conversation
This was referenced Feb 28, 2026
Member
Author
Merging this PR will not alter performance
Comparing Footnotes
|
Kind::set_* method visible only within lexerToken::set_* method visible only within lexer
This was referenced Feb 28, 2026
Contributor
There was a problem hiding this comment.
Pull request overview
Restricts Token mutation APIs to the lexer module so tokens can’t be modified elsewhere in the parser crate, strengthening the invariant that only the lexer constructs and mutates token metadata.
Changes:
- Change
Token::set_start,set_end,set_kind, and flag setters frompub(crate)topub(super)to limit visibility tolexerand its submodules.
0d8f3e4 to
e50063c
Compare
697c7be to
c32a896
Compare
Contributor
Merge activity
|
c32a896 to
834c7d1
Compare
e50063c to
7eec16b
Compare
…9852) `Token::set_*` methods should not be accessible outside of the lexer. Only the lexer creates tokens, and it should not be possible to alter them, to ensure we can rely on them being accurate throughout the parser. Make `Token::set_start` etc `pub(super)` instead of `pub(crate)`.
834c7d1 to
29a5a68
Compare
graphite-app bot
pushed a commit
that referenced
this pull request
Feb 28, 2026
#19852 made `Token`s impossible to mutate outside of the lexer. Add an escape hatch to provide methods to mutate them, for use in ESTree conversion, behind a `mutate_tokens` Cargo feature. Also add a `Token::set_span` method, to complement the other setter methods.
This was referenced Feb 28, 2026
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.

Token::set_*methods should not be accessible outside of the lexer. Only the lexer creates tokens, and it should not be possible to alter them, to ensure we can rely on them being accurate throughout the parser.Make
Token::set_startetcpub(super)instead ofpub(crate).