Skip to content

parser: fix tuple field parsing in offset_of expansion - #23320

Open
Pewpenguin wants to merge 1 commit into
rust-lang:masterfrom
Pewpenguin:fix/23178
Open

parser: fix tuple field parsing in offset_of expansion#23320
Pewpenguin wants to merge 1 commit into
rust-lang:masterfrom
Pewpenguin:fix/23178

Conversation

@Pewpenguin

@Pewpenguin Pewpenguin commented Sep 8, 2026

Copy link
Copy Markdown

Fixes #23178.

Fix tuple field parsing in offset_of expansions.

Added a parser test for tuple field paths.

@rustbot rustbot added the S-waiting-on-review Status: Awaiting review from the assignee but also interested parties. label Sep 8, 2026

@ChayimFriedman2 ChayimFriedman2 left a comment

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

The flat things makes this already-hacky thing super duper hacky. I don't want that.

Instead we should go back to basics. A float split event should just take the current pending float, and split it, so that the next two/three tokens are INT_NUMBER, DOT and perhaps another INT_NUMBER. This is not possible to do literally, but possible to emulate quite well. The plan is:

  • The parser has a split_float() method. This methods does two things: emit a FloatSplitHack { ends_in_dot } event, and also changes a field in Parser to signal "we've split a float". This field will be an enum FloatSplitStage { None, BeforeFirstInt, BeforeDot, BeforeSecondInt } and peek/bump methods will consider it.
  • The parser, when needed, will just call this method then proceeds to do parsing normally.
  • Consumers of the parser's events will also have a field similar to the parser's to track in-flight splitting (we can't split more than one float at a time).

View changes since this review

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

Labels

S-waiting-on-review Status: Awaiting review from the assignee but also interested parties.

Projects

None yet

Development

Successfully merging this pull request may close these issues.

FP Syntax Error in Expansion: expected integer, identifier, self, super, crate, or Self tuple type

3 participants