tafia / quick-protobuf

A rust implementation of protobuf parser
MIT License
446 stars 82 forks source link

Unable to import a nested message that uses an outer message. #241

Closed sinistersnare closed 1 year ago

sinistersnare commented 1 year ago

This has a complicated reproduction strategy, so I made a small repro-repo for it. You can find it here.

Basically, if I have a file here:

// uses.proto

syntax = "proto2";

import "imports/thing.proto";

message o {
    optional string name = 1;
    optional pkg.Outer ack = 2;
}

and another

// imports/thing.proto
syntax = "proto2";

package pkg;

message Outer {
  message Inner {
    optional Other other = 3;
  }
}

message Other {
}

(In practice this file is actually the google/protobufs/descriptor.proto)

When I run my Build.rs file with this setup, I get an error like:

  thread 'main' panicked at 'called `Result::unwrap()` on an `Err` value: MessageOrEnumNotFound("Other")', build.rs:34:42
  note: run with `RUST_BACKTRACE=1` environment variable to display a backtrace

I did not write these .proto files, I am using them as is, and I am pretty sure they should work as is.

Is this correct usage of protobufs? If so, can I help add support to fix this?

sinistersnare commented 1 year ago

This seems to be fixed in master.