Importing proto with dotted name
- Dominant language
- Rust
- Stars
- 12.5k
- Forks
- 1.3k
- Avg merge
- 4d 7h
- Merged PRs (30d)
- 24
Description
## Bug Report
### Version
tonic v0.11.0
tonic-build v0.11.0
### Platform
Darwin 23.2.0 Darwin Kernel Version 23.2.0: Wed Nov 15 21:55:06 PST 2023; root:xnu-10002.61.3~2/RELEASE_ARM64_T6020 arm64
### Description
I have the following two proto files:
`foobar.proto`
```proto
syntax = "proto3";
package foo.bar;
message Foo {}
message Bar {}
```
`example.proto`
```proto
syntax = "proto3";
package example;
import "foobar.proto";
service Example {
rpc example(foo.bar.Foo) returns (foo.bar.Bar);
}
```
and a `main.rs` file:
```rust
use tonic::{Request, Response, Status};
use pb::*;
pub mod pb {
tonic::include_proto!("example");
}
#[derive(Debug, Default)]
struct Service;
#[tonic::async_trait]
impl example_service_server::ExampleService for Service {
async fn void(&self, _request: Request) -> Result, Status> {
todo!()
}
}
fn main() {}
```
When running `cargo clippy`, the following output prints:
```
error[E0433]: failed to resolve: could not find `foo` in the crate root
--> [...]/target/debug/build/tonic_bug_mre-913b1807619270b3/out/example.rs:88:60
|
88 | request: impl tonic::IntoRequest,
| ^^^ could not find `foo` in the crate root
... many more similar error messages
```
It seems like tonic is not set up to handle packages with dotted names (i.e. `foo.bar`) in imports.
If the dotted package is 'standalone', that works. Is there anything I overlooked to make this work?
Contributor guide
Assessment
This issue has not been assessed yet.