Skip to content

Generate better formatted Rust code#8919

Open
csmulhern wants to merge 2 commits intogoogle:masterfrom
csmulhern:cleanup
Open

Generate better formatted Rust code#8919
csmulhern wants to merge 2 commits intogoogle:masterfrom
csmulhern:cleanup

Conversation

@csmulhern
Copy link
Contributor

@csmulhern csmulhern commented Feb 4, 2026

There are no behavioral changes in the PR. This simply updates the Rust generator to produce better formatted code, with the following changes:

  1. Whitespace is added between function definitions.
  2. Newline insertions are better factored / tracked, so you don't end up with two consecutive empty lines.
  3. Code inside mod blocks is properly indented.
  4. #[inline] annotations have been moved below function documentation, which is the expected style.

The first commit contains the relevant changes.
The second commit simply regenerates all the example code.

It would be easiest to review the commits separately.

@github-actions github-actions bot added c++ rust codegen Involving generating code from schema labels Feb 4, 2026
@csmulhern
Copy link
Contributor Author

@jtdavis777 it looks like you've been reviewing recent PRs for this project. I have a few more Rust style cleanups I would love to do. They aren't functional changes, so should be pretty straightforward to review. Can I send them your way?

@jtdavis777
Copy link
Collaborator

Sure I can add this to the docket. I am not a rust dev at all but am happy to look this over.

@csmulhern
Copy link
Contributor Author

Great, thank you!

Copy link
Collaborator

@jtdavis777 jtdavis777 left a comment

Choose a reason for hiding this comment

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

Overall the changes to the generator code look good, I have two questions

code_ += " }";
code_ += " }";
code_ += "}";
code_ += "";
Copy link
Collaborator

Choose a reason for hiding this comment

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

curious why you have a function to do this, but also a bunch of new lines that don't use the function?


const Namespace* CurrentNameSpace() const { return cur_name_space_; }

void AddLineBeforeContentIfNeeded() { code_ += ""; }
Copy link
Collaborator

Choose a reason for hiding this comment

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

this function seems a little misnamed -- there is no check here

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

Labels

c++ codegen Involving generating code from schema rust

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants

Comments