I'd like to ask a question, I'm encountering this problem when compiling proto files with rust tonic-build
|
11 | super::super::super::trace::v1::ResourceSpans,
| ^^^^^ there are too many leading `super` keywords
For more information about this error, try `rustc --explain E0433`.
I'm going to build the client file for this proto file ,and I'm cloning the entire opentelemetry folder.
This is my build file.
fn main() -> Result<(), Box<dyn std::error::Error>> {
tonic_build::configure()
.protoc_arg("--experimental_allow_proto3_optional")
.build_server(false)
.compile(
&["opentelemetry/proto/collector/trace/v1/trace_service.proto"],
&["."],
)?;
Ok(())
}
The solution has been found. Thank you.
opened 11:03PM - 14 Aug 21 UTC
closed 02:36PM - 28 Sep 22 UTC
C-enhancement
E-help-wanted
A-build
E-medium
`tonic-build`: 0.5.2
Trying to use googleapi. Google api proto files are in t… heir own directory within the project `projectname/protos`.
`projectname/`
`projectname/protos`
`projectname/src`
`projectname/src/speech`
`projectname/build.rs`
`projectname/target`
etc
```rust
// build.rs
fn main() -> Result<(), Box<dyn std::error::Error>> {
tonic_build::configure()
.build_client(true)
.build_server(false)
.format(false)
.out_dir("src/speech")
.compile(&["protos/googleapis/google/cloud/speech/v1/cloud_speech.proto"], &["protos/googleapis"])?;
Ok(())
}
```
`cargo build` and the .rs files are generated in `src/speech`. Now the problem.
```rust
// main.rs
#[path = "speech"]
pub mod speech {
#[path = "google.rpc.rs"]
pub mod rpc;
#[path = "google.longrunning.rs"]
pub mod longrunning;
#[path = "google.cloud.speech.v1.rs"]
pub mod transcriber;
}
```
```
error[E0433]: failed to resolve: there are too many leading `super` keywords
--> src/speech/google.cloud.speech.v1.rs:588:53
|
588 | pub error: ::core::option::Option<super::super::super::rpc::Status>,
| ^^^^^ there are too many leading `super` keywords
error[E0433]: failed to resolve: there are too many leading `super` keywords
--> src/speech/google.cloud.speech.v1.rs:726:3457
|
726 | ... :: Response < super :: super :: super :: super :: longrunning :: Operation > , tonic :: Status > { self . inner . ready () . await . ...
| ^^^^^ there are too many leading `super` keywords
error[E0698]: type inside `async fn` body must be known in this context
--> src/speech/google.cloud.speech.v1.rs:726:3690
|
726 | ... . into ())) }) ? ; let codec = tonic :: codec :: ProstCodec :: default () ; let path = http :: uri :: PathAndQuery :: from_static ("/...
| ^^^^^^^^^^^^^^^^^^^^^^^^^^^^ cannot infer type for type parameter `U`
|
note: the type is part of the `async fn` body because of this `await`
--> src/speech/google.cloud.speech.v1.rs:726:3847
|
726 | ...peech/LongRunningRecognize") ; self . inner . unary (request . into_request () , path , codec) . await } # [doc = " Performs bidirecti...
| ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
error[E0698]: type inside `async fn` body must be known in this context
--> src/speech/google.cloud.speech.v1.rs:726:3690
|
726 | ...t codec = tonic :: codec :: ProstCodec :: default () ; let path = http :: uri :: PathAndQuery :: from_static ("/google.cloud.speech.v1...
| ^^^^^^^^^^^^^^^^^^^^^^^^^^^^ cannot infer type for type parameter `M2` declared on the associated function `unary`
|
note: the type is part of the `async fn` body because of this `await`
--> src/speech/google.cloud.speech.v1.rs:726:3847
|
726 | ...peech/LongRunningRecognize") ; self . inner . unary (request . into_request () , path , codec) . await } # [doc = " Performs bidirecti...
| ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
error[E0283]: type annotations needed
--> src/speech/google.cloud.speech.v1.rs:583:28
|
583 | #[derive(Clone, PartialEq, ::prost::Message)]
| ^^^^^^^^^^^^^^^^ cannot infer type
|
= note: cannot satisfy `_: Default`
note: required by `std::default::Default::default`
--> /home/gromneer/.rustup/toolchains/nightly-x86_64-unknown-linux-gnu/lib/rustlib/src/rust/library/core/src/default.rs:116:5
|
116 | fn default() -> Self;
| ^^^^^^^^^^^^^^^^^^^^^
= note: this error originates in the derive macro `::prost::Message` (in Nightly builds, run with -Z macro-backtrace for more info)
```