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

compile error with required group proto2 message #742

Open
kristopherbullinger opened this issue Sep 29, 2024 · 0 comments
Open

compile error with required group proto2 message #742

kristopherbullinger opened this issue Sep 29, 2024 · 0 comments

Comments

@kristopherbullinger
Copy link

// protos/group.proto
syntax = "proto2";
message Foo {
  required group Data = 201 { // <------- `required group`
    required int32 group_int32 = 202;
    required uint32 group_uint32 = 203;
  }
}
// build.rs
fn main() {
    println!("cargo:rerun-if-changed=protos/group.proto");
    protobuf_codegen::Codegen::new()
        .pure()
        .includes(&["protos"])
        .input("protos/oneof.proto")
        .cargo_out_dir("protos")
        .run_from_script();
}
// src/main.rs
mod protos {
    include!(concat!(env!("OUT_DIR"), "/protos/mod.rs"));
}
use protos::group;
fn main() {}

Produces compile error:

error[E0609]: no field `data` on type `&Foo`
  --> /protobuf-build-test/target/debug/build/oneof-7aa1b7e9780d5143/out/protos/group.rs:63:17
   |
63 |         if self.data.is_none() {
   |                 ^^^^ unknown field
   |
   = note: available field is: `special_fields`

It seems that a group is merely rendered as a comment in the generated output struct:

// @@protoc_insertion_point(message:Foo)
#[derive(PartialEq,Clone,Default,Debug)]
pub struct Foo {
    // message fields
    // data: <group>    <------------------------------
    // special fields
    // @@protoc_insertion_point(special_field:Foo.special_fields)
    pub special_fields: ::protobuf::SpecialFields,
}

Perhaps it should be rendered as a data: Option<foo::Data>, ?

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