Skip to content

parser: replace internal frontmatter lex with rustc_lexer::tokenize - #23289

Draft
dimxy wants to merge 5 commits into
rust-lang:masterfrom
dimxy:eliminate-internal-frontmatter-lex
Draft

parser: replace internal frontmatter lex with rustc_lexer::tokenize#23289
dimxy wants to merge 5 commits into
rust-lang:masterfrom
dimxy:eliminate-internal-frontmatter-lex

Conversation

@dimxy

@dimxy dimxy commented Sep 3, 2026

Copy link
Copy Markdown
Contributor

Currently RA has its own shebang and frontmatter tokenizing code while the rustc tokenizer also does this job.
This PR eliminates internal frontmatter lex code and uses rustc_lexer::tokenize instead.
There are important notes about this code though:

  • Rustc performs its frontmatter validation in the parser (not in the tokenizer) so this PR has to borrow and implement those checks from the rustc parser.
  • Unlike RA, rustc_lexer::tokenize receives only normalized input (CRLF -> LF), so when used inside RA, it may return '\r' suffix in the frontmatter token and treat some infostrings with ending '\r' as invalid. Both these cases are processed in the PR's validate_frontmatter code. A test was added for CRLF input as well.

Fixes #23144. Added a test case.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

FP Syntax Error: expected an item

1 participant