Add dead-code ignore annotation to codegen. - #2827
Open
nathanielford wants to merge 2 commits into
Open
Conversation
…g the same protobuf for both a gRPC-Rust client and a Tonic server.
Contributor
|
Can you also re-generated the routeguide and helloworld example code by running the following? cd examples
cargo build --features grpc-protobuf-build/build-plugin,grpc-routeguide |
Contributor
|
@dfawley had suppressed these warnings by adding annotations in the application code: We may be able to remove those now. |
arjan-bal
approved these changes
Aug 21, 2026
arjan-bal
left a comment
Contributor
There was a problem hiding this comment.
LGTM, with a couple of minor comments.
dfawley
reviewed
Aug 21, 2026
| /// Generated client implementations. | ||
| pub mod $client_mod$ { | ||
| #![allow( | ||
| unused_variables, |
Member
There was a problem hiding this comment.
Do we need all these? I wouldn't have expected the unused variables or imports.
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Motivation
When building a client with
grpc-rustand a server withtonic, the un-ignored client code generates a warning:unused import: grpc::client::*.This is because Tonic's build process deals with these warnings later, but
grpc-rustbuild process has not put anything in place for that yet.Solution
Add the same annotations to the generated client code that exists on the generated server code (see lines 713-720 in the same file), during code generation. We may want to revisit this later, but this is the most straightforward solution for the moment.