Escape Rust keywords in generated RPC method names#26
Merged
Conversation
An RPC method whose snake_case name collides with a Rust keyword (e.g. `rpc Move(...)` -> `move`) caused codegen to emit invalid identifiers that syn rejects at build-script time. Route method-name idents through buffa_codegen::idents::make_field_ident, which raw-escapes keywords (`r#move`) and suffixes the few that cannot be raw (`self_`). The `_with_options` client variant is already safe since the suffix de-keywords it. Fixes #23.
aaomidi
approved these changes
Apr 2, 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 subscribe to this conversation on GitHub.
Already have an account?
Sign in.
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.
Fixes #23.
An RPC method whose snake_case name collides with a Rust keyword (e.g.
rpc Move(...)→move) caused codegen to emit invalid identifiers, failing at build-script time withexpected identifier, found keyword.This routes method-name idents through
buffa_codegen::idents::make_field_ident, which already handles this for message fields:move→r#moveself→self_Covers all four emission sites (trait method, route registration, server dispatch, client method) plus the client doc-comment example. The
_with_optionsclient variant is left as-is since the suffix already de-keywords it.Adds regression tests for both escaping paths (
MoveandSelf), each asserting the full output round-trips throughsyn::parse_str.