Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

[prost] Fix handling of message names with acronyms #2193

Merged
merged 1 commit into from
Oct 12, 2023

Conversation

william-smith-skydio
Copy link
Contributor

For example, the message name SomeAPI. Internally protoc-gen-prost converts this to upper camel case, but rules_rust is not doing that when populating the --extern_path args. The result is that when a message with an acroynym in its name is included in another proto file, the generated code has a type name with the wrong casing.

Without this fix, the added test fails to build like this:

error[E0412]: cannot find type `NameWithCAPS` in module `camel_case_proto::camel_case`
 --> bazel-out/k8-fastbuild/bin/proto/prost/private/tests/camel_case/another_proto.lib.rs:9:75
  |
9 |         pub inner: ::core::option::Option<::camel_case_proto::camel_case::NameWithCAPS>,
  |                                                                           ^^^^^^^^^^^^ help: a struct with a similar name exists: `NameWithCaps`
 --> bazel-out/k8-fastbuild/bin/proto/prost/private/tests/camel_case/camel_case_proto.lib.rs:7:5
  |
  = note: similarly named struct `NameWithCaps` defined here

error: aborting due to previous error

For example, the message name `SomeAPI`. Internally protoc-gen-prost
[converts](https://github.com/neoeinstein/protoc-gen-prost/blob/1a6d3593622af18b75a4a79f545f8530cdaf444f/protoc-gen-tonic/src/util.rs#L14)
this to upper camel case, but rules_rust is not doing that when
populating the `--extern_path` args. The result is that when a message
with an acroynym in its name is included in another proto file, the
generated code has a type name with the wrong casing.

Without this fix, the added test fails to build like this:

```
error[E0412]: cannot find type `NameWithCAPS` in module `camel_case_proto::camel_case`
 --> bazel-out/k8-fastbuild/bin/proto/prost/private/tests/camel_case/another_proto.lib.rs:9:75
  |
9 |         pub inner: ::core::option::Option<::camel_case_proto::camel_case::NameWithCAPS>,
  |                                                                           ^^^^^^^^^^^^ help: a struct with a similar name exists: `NameWithCaps`
 --> bazel-out/k8-fastbuild/bin/proto/prost/private/tests/camel_case/camel_case_proto.lib.rs:7:5
  |
  = note: similarly named struct `NameWithCaps` defined here

error: aborting due to previous error
```
@william-smith-skydio william-smith-skydio changed the title Fix handling of message names with acronyms [prost] Fix handling of message names with acronyms Oct 12, 2023
Copy link
Collaborator

@UebelAndre UebelAndre left a comment

Choose a reason for hiding this comment

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

Thanks!

@UebelAndre UebelAndre merged commit 0a3bf9e into bazelbuild:main Oct 12, 2023
3 checks passed
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.

2 participants