Skip to content

Add dead-code ignore annotation to codegen. - #2827

Open
nathanielford wants to merge 2 commits into
grpc:masterfrom
nathanielford:refactor/codegen-ignore-dead
Open

Add dead-code ignore annotation to codegen.#2827
nathanielford wants to merge 2 commits into
grpc:masterfrom
nathanielford:refactor/codegen-ignore-dead

Conversation

@nathanielford

@nathanielford nathanielford commented Aug 20, 2026

Copy link
Copy Markdown
Contributor

Motivation

When building a client with grpc-rust and a server with tonic, 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-rust build 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.

@nathanielford
nathanielford marked this pull request as ready for review August 20, 2026 22:45
@arjan-bal

Copy link
Copy Markdown
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

@arjan-bal

Copy link
Copy Markdown
Contributor

@dfawley had suppressed these warnings by adding annotations in the application code:

#[allow(unused, clippy::all)]

We may be able to remove those now.

@arjan-bal arjan-bal left a comment

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

LGTM, with a couple of minor comments.

@arjan-bal arjan-bal assigned nathanielford and unassigned arjan-bal Aug 21, 2026
@arjan-bal arjan-bal added the C-cleanup Category: PRs that clean code up or issues documenting cleanup. label Aug 21, 2026
/// Generated client implementations.
pub mod $client_mod$ {
#![allow(
unused_variables,

Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Do we need all these? I wouldn't have expected the unused variables or imports.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

C-cleanup Category: PRs that clean code up or issues documenting cleanup.

Projects

None yet

Development

Successfully merging this pull request may close these issues.

3 participants