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

Module generated for 'oneof' field conflicts with module generated for package #1004

Open
kriomant opened this issue Mar 16, 2024 · 0 comments

Comments

@kriomant
Copy link

Here is reduced copy of what I met in .proto files of real service. This service is out of my control, I just want to create client for it.

proto/foo.proto

syntax = "proto3";

package foo;

import "foo/bar.proto";

message Bar {
  oneof bar {
    bar.This this = 1;
    bar.That that = 2;
  }
}

proto/foo/bar.proto

syntax = "proto3";

package foo.bar;

message This {}
message That {}

src/lib.rs

pub mod foo {
    include!(concat!(env!("OUT_DIR"), "/foo.rs"));
    pub mod bar {
        include!(concat!(env!("OUT_DIR"), "/foo.bar.rs"));
    }
}

Such proto files lead to error:

error[E0428]: the name `bar` is defined multiple times
 --> /Users/kriomant/.cargo/target/debug/build/proto-67d1c5fed5b166e2/out/foo.rs:8:1
  |
8 | pub mod bar {
  | ^^^^^^^^^^^ `bar` redefined here
  |
 ::: src/lib.rs:3:5
  |
3 |     pub mod bar {
  |     ----------- previous definition of the module `bar` here
  |
  = note: `bar` must be defined only once in the type namespace of this module

This is because each message with 'oneof' field generates module with name corresponding to that message name.
In this case it conflicts with existing proto package.

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

No branches or pull requests

1 participant