Repository navigation
fix(internal/sidekick/rust): match prost-build module snake_case - #7806
Merged
Merged
Conversation
prostMessageModulePath previously used strcase.ToSnake to compute nested message module names for prost conversions. However, strcase.ToSnake inserts an underscore between a letter and a digit, turning names like CVSSv3 into cvs_sv_3, whereas prost-build uses heck::ToSnakeCase which only splits on case transitions and non-alphanumeric boundaries, producing cvs_sv3. Implement toProstWords and toProstSnake following heck's word boundary rules so that both toProstSnake and toProstPascal match prost-build's identifier formatting.
Contributor
There was a problem hiding this comment.
Code Review
This pull request introduces the toProstWords and toProstSnake functions in internal/sidekick/rust/codec.go to align symbol name conversions (snake_case and PascalCase) with the word boundary rules of prost-build (from the Rust heck crate). It also updates escapeKeyword to handle the _ keyword, identifiers starting with digits, and the Rust 2024+ reserved keyword gen. Corresponding unit tests have been added in internal/sidekick/rust/codec_test.go to verify these changes. There are no review comments, so I have no feedback to provide.
Contributor
Author
|
Verified the test cases against Proto:syntax = "proto3";
package test.pkg;
message Parent {
message CVSSv3 { message Nested {} }
message V2Beta1 { message Nested {} }
message HTTP2Frame { message Nested {} }
message OAuth2Config { message Nested {} }
message VertexAISearch { message Nested {} }
message XMLHttpRequest { message Nested {} }
message FIELD_NAME11 { message Nested {} }
message FieldNamE11 { message Nested {} }
message Gen { message Nested {} }
message Self { message Nested {} }
message Mod { message Nested {} }
message ABC123dEEf456FOO { message Nested {} }
}Output generated by `prost-build`:// This file is @generated by prost-build.
#[derive(Clone, Copy, PartialEq, Eq, Hash, ::prost::Message)]
pub struct Parent {}
/// Nested message and enum types in `Parent`.
pub mod parent {
#[derive(Clone, Copy, PartialEq, Eq, Hash, ::prost::Message)]
pub struct CvsSv3 {}
/// Nested message and enum types in `CVSSv3`.
pub mod cvs_sv3 {
#[derive(Clone, Copy, PartialEq, Eq, Hash, ::prost::Message)]
pub struct Nested {}
}
#[derive(Clone, Copy, PartialEq, Eq, Hash, ::prost::Message)]
pub struct V2Beta1 {}
/// Nested message and enum types in `V2Beta1`.
pub mod v2_beta1 {
#[derive(Clone, Copy, PartialEq, Eq, Hash, ::prost::Message)]
pub struct Nested {}
}
#[derive(Clone, Copy, PartialEq, Eq, Hash, ::prost::Message)]
pub struct Http2Frame {}
/// Nested message and enum types in `HTTP2Frame`.
pub mod http2_frame {
#[derive(Clone, Copy, PartialEq, Eq, Hash, ::prost::Message)]
pub struct Nested {}
}
#[derive(Clone, Copy, PartialEq, Eq, Hash, ::prost::Message)]
pub struct OAuth2Config {}
/// Nested message and enum types in `OAuth2Config`.
pub mod o_auth2_config {
#[derive(Clone, Copy, PartialEq, Eq, Hash, ::prost::Message)]
pub struct Nested {}
}
#[derive(Clone, Copy, PartialEq, Eq, Hash, ::prost::Message)]
pub struct VertexAiSearch {}
/// Nested message and enum types in `VertexAISearch`.
pub mod vertex_ai_search {
#[derive(Clone, Copy, PartialEq, Eq, Hash, ::prost::Message)]
pub struct Nested {}
}
#[derive(Clone, Copy, PartialEq, Eq, Hash, ::prost::Message)]
pub struct XmlHttpRequest {}
/// Nested message and enum types in `XMLHttpRequest`.
pub mod xml_http_request {
#[derive(Clone, Copy, PartialEq, Eq, Hash, ::prost::Message)]
pub struct Nested {}
}
#[derive(Clone, Copy, PartialEq, Eq, Hash, ::prost::Message)]
pub struct FieldName11 {}
/// Nested message and enum types in `FIELD_NAME11`.
pub mod field_name11 {
#[derive(Clone, Copy, PartialEq, Eq, Hash, ::prost::Message)]
pub struct Nested {}
}
#[derive(Clone, Copy, PartialEq, Eq, Hash, ::prost::Message)]
pub struct FieldNamE11 {}
/// Nested message and enum types in `FieldNamE11`.
pub mod field_nam_e11 {
#[derive(Clone, Copy, PartialEq, Eq, Hash, ::prost::Message)]
pub struct Nested {}
}
#[derive(Clone, Copy, PartialEq, Eq, Hash, ::prost::Message)]
pub struct Gen {}
/// Nested message and enum types in `Gen`.
pub mod r#gen {
#[derive(Clone, Copy, PartialEq, Eq, Hash, ::prost::Message)]
pub struct Nested {}
}
#[derive(Clone, Copy, PartialEq, Eq, Hash, ::prost::Message)]
pub struct Self_ {}
/// Nested message and enum types in `Self`.
pub mod self_ {
#[derive(Clone, Copy, PartialEq, Eq, Hash, ::prost::Message)]
pub struct Nested {}
}
#[derive(Clone, Copy, PartialEq, Eq, Hash, ::prost::Message)]
pub struct Mod {}
/// Nested message and enum types in `Mod`.
pub mod r#mod {
#[derive(Clone, Copy, PartialEq, Eq, Hash, ::prost::Message)]
pub struct Nested {}
}
#[derive(Clone, Copy, PartialEq, Eq, Hash, ::prost::Message)]
pub struct Abc123dEEf456Foo {}
/// Nested message and enum types in `ABC123dEEf456FOO`.
pub mod abc123d_e_ef456_foo {
#[derive(Clone, Copy, PartialEq, Eq, Hash, ::prost::Message)]
pub struct Nested {}
}
} |
suzmue
marked this pull request as ready for review
October 22, 2026 17:45
coryan
approved these changes
Oct 27, 2026
suzmue
enabled auto-merge (squash)
October 27, 2026 16:58
sofisl
pushed a commit
that referenced
this pull request
Oct 27, 2026
🤖 I have created a release *beep* *boop* --- ## [0.50.0](v0.49.0...v0.50.0) (2026-10-27) ### Features * **internal/librarian/java:** parallelize generation and formatting ([#7813](#7813)) ([bf3b603](bf3b603)) ### Bug Fixes * **internal/librarian:** check explicit API paths in findExistingLibraryForAPI ([#7816](#7816)) ([00ae0ab](00ae0ab)), refs [#7814](#7814) * **internal/sidekick/rust_prost:** map BytesValue ([#7798](#7798)) ([7080958](7080958)) * **internal/sidekick/rust:** match prost-build module snake_case ([#7806](#7806)) ([8790f1b](8790f1b)) * **sidekick/swift:** support google.api.HttpBody in REST ([#7811](#7811)) ([d427811](d427811)) * **swift:** strip backticks from DocC xref links ([#7804](#7804)) ([6a931c5](6a931c5)), refs [#751](#751) --- This PR was generated with [Release Please](https://github.com/googleapis/release-please). See [documentation](https://github.com/googleapis/release-please#release-please). Co-authored-by: release-please[bot] <55107282+release-please[bot]@users.noreply.github.com>
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 join this conversation on GitHub.
Already have an account?
Sign in to comment
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.
prostMessageModulePath previously used strcase.ToSnake to compute nested message module names for prost conversions. However, strcase.ToSnake inserts an underscore between a letter and a digit, turning names like CVSSv3 into cvs_sv_3, whereas prost-build uses heck::ToSnakeCase which only splits on case transitions and non-alphanumeric boundaries, producing cvs_sv3.
Implement toProstWords and toProstSnake following heck's word boundary rules so that both toProstSnake and toProstPascal match prost-build's identifier formatting.