parser: fix tuple field parsing in offset_of - #23287
Conversation
|
The Rust, Rust Cross, rustfmt, clippy, miri, and analysis-stats checks pass. The remaining failures are unrelated to this PR:
I reproduced the relevant failures locally and confirmed they are not introduced by this change. |
|
I suspect you used AI without disclosing that. Please note that our AI policy requires disclosure. Make sure to read the policy and follow it. |
|
Thanks for taking a look. To be fully transparent about AI usage per the policy: Where AI helped: I used AI as an exploratory tool to navigate event.rs and syntax-bridge, trace how FloatSplitHack was originally wired up in commit 6fa6efe, and help deduplicate the float-splitting helper between FIELD_EXPR and offset_of. Happy to make any adjustments or refactor further if you’d prefer a different approach here. |
I guess no human would write such section to PR description |
|
Fair catch — that template was indeed generated when I first opened the PR. I've updated the PR description now in my own words. |
Fixes #23178.
When using offset_of with nested tuple fields such as 0.1.1.1, the lexer parses parts of the field path (0.1 and 1.1) as float literals. This makes offset_of reject the expression with a syntax error.
This PR splits float literals while parsing offset_of into field indices and dots, so the resulting events match the structure expected by OFFSET_OF_EXPR. This follows the same general approach used by rustc in break_up_float.
Also adds an inline regression test covering nested tuple fields.
AI disclosure: Used AI as an exploratory tool to navigate the parser/event plumbing and help with the refactoring.