Skip to content

codegen: skip rustfmt for generated mod.rs - #335

Merged
lifupan merged 2 commits into
masterfrom
fix/generated-module-order
Sep 30, 2026
Merged

lifupan merged 2 commits into
masterfrom
fix/generated-module-order

Conversation

@Tim-Zhang

@Tim-Zhang Tim-Zhang commented Sep 30, 2026 •

Copy link
Copy Markdown
Member

Generated mod.rs files append ttrpc service modules after rust-protobuf message modules, causing downstream cargo fmt --check to fail on their combined ordering. Add a file-level rustfmt skip attribute below the first-line // @generated marker. Repeated generation preserves existing declarations, comments, and attributes without duplicating the header.

Stop tracking the example's generated sync and async mod.rs files and ignore regenerated indexes. Keep the handwritten protocol entry point tracked, with its existing rustfmt skip attributes so formatting also works before generation.

Validation: a fresh cargo check --offline -p ttrpc-example --examples passed and regenerated both ignored indexes. cargo fmt --all -- --check passed before and after generation. Runtime/integration tests were not rerun for this cleanup.

Add a file-level rustfmt skip attribute below the generated marker
when creating or updating mod.rs. Preserve existing declarations,
comments, and attributes without duplicating the generated header.

Cover fresh indexes and indexes previously written by rust-protobuf.

Signed-off-by: Tim Zhang <tim@hyper.sh>
@Tim-Zhang
Tim-Zhang force-pushed the fix/generated-module-order branch from 41a9c0d to 89f7248 Compare September 30, 2026 08:36
@Tim-Zhang Tim-Zhang changed the title codegen: skip rustfmt for generated module indexes codegen: skip rustfmt for generated mod.rs Sep 30, 2026
@Tim-Zhang
Tim-Zhang force-pushed the fix/generated-module-order branch from 89f7248 to 5cbbd68 Compare September 30, 2026 08:39
Remove the generated sync and async module indexes from version control.
Keep the handwritten protocol entry point tracked and ignore regenerated
indexes alongside the other generated bindings.

Signed-off-by: Tim Zhang <tim@hyper.sh>
@Tim-Zhang
Tim-Zhang force-pushed the fix/generated-module-order branch from 5cbbd68 to c51a97b Compare September 30, 2026 08:44
@lifupan
lifupan merged commit 556d29c into master Sep 30, 2026
15 checks passed
@lifupan
lifupan deleted the fix/generated-module-order branch September 30, 2026 09:00
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.

3 participants