rules_rust icon indicating copy to clipboard operation
rules_rust copied to clipboard

[Bugfix] protos with the same package name prefix fail to compile

Open houqp opened this issue 1 year ago • 3 comments

When proto files sharing the same package name prefixes reference types from each other, protoc_wrapper will generate code with incorrect module scope resulting in the following compilation error:

error[E0412]: cannot find type `CMessage` in module `super`
  --> bazel-out/darwin_arm64-fastbuild/bin/proto/prost/private/tests/shared_package_prefix/shared_pkg_prefix_proto.lib.rs:21:46
   |
21 |         pub c: ::core::option::Option<super::CMessage>,
   |                                              ^^^^^^^^ not found in `super`
   |
help: consider importing this struct
   |
15 +     use crate::pkg::CMessage;
   |
help: if you import `CMessage`, refer to it directly
   |
21 -         pub c: ::core::option::Option<super::CMessage>,
21 +         pub c: ::core::option::Option<CMessage>,

This Patch refactors the module tree walk implementation to ensure generated rust code are wrapped with the correct rust module hierarchy.

houqp avatar Oct 06 '24 22:10 houqp

Thanks for your pull request! It looks like this may be your first contribution to a Google open source project. Before we can look at your pull request, you'll need to sign a Contributor License Agreement (CLA).

View this failed invocation of the CLA check for more information.

For the most up to date status, view the checks section at the bottom of the pull request.

google-cla[bot] avatar Oct 06 '24 22:10 google-cla[bot]

@UebelAndre the CI error looks like infra related and not caused by my change?

houqp avatar Oct 09 '24 05:10 houqp

/cc @freeformstu

stevebarrau avatar Jun 13 '25 09:06 stevebarrau