Proto package name must match filename
- Dominant language
- Rust
- Stars
- 12.5k
- Forks
- 1.3k
- Avg merge
- 4d 7h
- Merged PRs (30d)
- 24
Description
## Bug Report
### Version
```
% cargo tree | grep tonic
├── tonic v0.7.2
└── tonic-build v0.7.2
```
### Platform
```
% uname -a
Darwin MacBook-Pro 20.6.0 Darwin Kernel Version 20.6.0: Wed Jun 23 00:26:31 PDT 2021; root:xnu-7195.141.2~5/RELEASE_X86_64 x86_64
```
### Description
`helloworld.proto`:
```
syntax = "proto3";
package helloworld;
import "proto/request.proto";
// The greeting service definition.
service Greeter {
// Sends a greeting
rpc SayHello (r.HelloRequest) returns (HelloReply) {}
}
// The response message containing the greetings
message HelloReply {
string message = 1;
}
```
`request.proto`:
```
syntax = "proto3";
package r;
// The request message containing the user's name.
message HelloRequest {
string name = 1;
}
```
This gives a lot of errors that all look like:
```
error[E0433]: failed to resolve: could not find `r` in the crate root
--> /Users/alelazar/Documents/helloworld-tonic/target/debug/build/helloworld-tonic-33d7ab904b011773/out/helloworld.rs:75:60
|
75 | request: impl tonic::IntoRequest,
| ^ could not find `r` in the crate root
```
This works fine if I change the package from `r` to `request` (and update relevant references)
Things also work fine if the packages match - changing `r` to `helloworld`.
There is a decent chance I'm just doing things wrong.
### Side Note
It would be nice if we could eschew package names altogether - in other languages, I normally only see packages specified in order to differentiate similarly named types. Rust/tonic is forcing me to update cross language proto use to have packages.
Contributor guide
Assessment
This issue has not been assessed yet.