Skip to content

fix: Parse inline asm with keyword as operand name - #23054

Merged
Veykril merged 1 commit into
rust-lang:masterfrom
ChayimFriedman2:asm-keyword
Aug 8, 2026
Merged

fix: Parse inline asm with keyword as operand name#23054
Veykril merged 1 commit into
rust-lang:masterfrom
ChayimFriedman2:asm-keyword

Conversation

@ChayimFriedman2

Copy link
Copy Markdown
Contributor

We already have this problem for format_args!(), and I fixed it in #21351 by something that was kinda a hack. Now that we face it the second time, I decided to take a more principled approach. We just remap the SyntaxKind, so everything after the parser sees a normal identifier.

I'm a bit worried that some things might expect identifiers to always parse as such (e.g. assists), but we already have edition-dependent keywords (although unlike them, here picking the correct edition won't fix things) and contextual keywords (although they're the opposite: identifiers that are turned into keywords). In any case, if there is some problematic code we can fix it.

Fixes #23052.

We already have this problem for `format_args!()`, and I fixed it in rust-lang#21351 by something that was kinda a hack. Now that we face it the second time, I decided to take a more principled approach. We just remap the `SyntaxKind`, so everything after the parser sees a normal identifier.

I'm a bit worried that some things might expect identifiers to always parse as such (e.g. assists), but we already have edition-dependent keywords (although unlike them, here picking the correct edition won't fix things) and contextual keywords (although they're the opposite: identifiers that are turned into keywords). In any case, if there is some problematic code we can fix it.
@rustbot rustbot added the S-waiting-on-review Status: Awaiting review from the assignee but also interested parties. label Aug 5, 2026

@Veykril Veykril left a comment

Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

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

I think this is okay to do, given this is effectively contextual keywords / edition dependent keywords but the other way around. And assists technically need to special case these already (which most don't I think). That is to say this will break some right now but i think thats fine.

We should likely fix that at some point in our make-infra to always check names and namesrefs before being emitted and transform them to the raw syntax if necessary

View changes since this review

@Veykril
Veykril added this pull request to the merge queue Aug 8, 2026
Merged via the queue into rust-lang:master with commit 7c1a831 Aug 8, 2026
18 checks passed
@rustbot rustbot removed the S-waiting-on-review Status: Awaiting review from the assignee but also interested parties. label Aug 8, 2026
@ChayimFriedman2
ChayimFriedman2 deleted the asm-keyword branch August 8, 2026 17:42
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: sym args in naked asm blocks

3 participants