Skip to content
This repository has been archived by the owner on Apr 8, 2024. It is now read-only.

protoc-rust-grpc doesn't take care of keywords such as async #167

Open
jschwinger233 opened this issue Nov 26, 2019 · 0 comments
Open

protoc-rust-grpc doesn't take care of keywords such as async #167

jschwinger233 opened this issue Nov 26, 2019 · 0 comments

Comments

@jschwinger233
Copy link

jschwinger233 commented Nov 26, 2019

considering the protobuf message possesses a field async, the generated grpc rust code will irritate compiler under 2018 edition.

here's a simple demonstration, add two lines in greeting example repo:

greeter $ git diff
diff --git a/grpc-examples/greeter/Cargo.toml b/grpc-examples/greeter/Cargo.toml
index 4477fde..4a5bc33 100644
--- a/grpc-examples/greeter/Cargo.toml
+++ b/grpc-examples/greeter/Cargo.toml
@@ -3,6 +3,7 @@ name = "grpc_examples_greeter"
 version = "0.0.0"
 authors = ["Stepan Koltsov <[email protected]>"]
 publish = false
+edition = "2018"

 [lib]
 doctest = false
diff --git a/grpc-examples/greeter/helloworld.proto b/grpc-examples/greeter/helloworld.proto
index 0bee1fc..dc3f75d 100644
--- a/grpc-examples/greeter/helloworld.proto
+++ b/grpc-examples/greeter/helloworld.proto
@@ -45,6 +45,7 @@ service Greeter {
 // The request message containing the user's name.
 message HelloRequest {
   string name = 1;
+  bool async = 2;
 }

 // The response message containing the greetings

and rustc would complain

error: expected identifier, found reserved keyword `async`
   --> grpc-examples/greeter/src/helloworld.rs:216:14
    |
216 |         self.async = false;
    |              ^^^^^ expected identifier, found reserved keyword
help: you can escape reserved keywords to use them as identifiers
    |
216 |         self.r#async = false;
    |              ^^^^^^^

error: aborting due to 11 previous errors

error: Could not compile `grpc_examples_greeter`.
Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.
Labels
None yet
Projects
None yet
Development

No branches or pull requests

1 participant