Skip to content

Conversation

arjan-bal
Copy link
Collaborator

In #2339 I was running into issues with udeps check in the CI. The udeps check runs on the entire Cargo workspace. When the tower feature exists in the examples crate, the check would fail with the following error why analysing the grpc crate.

cargo udeps --no-default-features --features tower
error: package `grpc v0.9.0-alpha.1 (/path/to/tonic/grpc)` does not have feature `tower`

help: an optional dependency with that name exists, but the `features` table includes it with the "dep:" syntax so it does not have an implicit feature with that name
Dependency `tower` would be enabled by these features:
        - `_runtime-tokio`

This seems to be happening because cargo creates a feature for each optional dependency under the hood. udeps is trying to find the feature named tower in the grpc crate, but can't find it.

When I try to add a feature named tower which simply enables dep:tower, udeps complains that the feature is unused:

cargo udeps --no-default-features --features tower` on grpc (55/67)
      Checking tokio v1.48.0
      Checking tokio-util v0.7.16
      Checking tokio-stream v0.1.17
      Checking tonic v0.14.1 (/home/runner/work/tonic/tonic/tonic)
      Checking h2 v0.4.12
      Checking tower v0.5.2
      Checking hyper v1.7.0
      Checking grpc v0.9.0-alpha.1 (/home/runner/work/tonic/tonic/grpc)
      Finished `dev` profile [unoptimized + debuginfo] target(s) in 3.85s
  info: Loading depinfo from "/home/runner/work/tonic/tonic/target/debug/deps/tonic-0640da7d9d17aa64.d"
  info: Loading depinfo from "/home/runner/work/tonic/tonic/target/debug/deps/grpc-2666c6a3d9526f13.d"
  unused dependencies:
  `grpc v0.9.0-alpha.1 (/home/runner/work/tonic/tonic/grpc)`
  └─── dependencies
       └─── "tower"
  Note: These dependencies might be used by other targets.
        To find dependencies that are not used by any target, enable `--all-targets`.
  Note: They might be false-positive.
        For example, `cargo-udeps` cannot detect usage of crates that are only used in doc-tests.
        To ignore some dependencies, write `package.metadata.cargo-udeps.ignore` in Cargo.toml.

I'm unsure if this is a bug in udeps.

I (incorrectly) assumed that the tower feature was not required in the examples crate and removed it. I re-checked and #2339 seems to have broken the tower-client and tower-server examples' builds.


This PR re-introduces the tower feature, fixing the tower examples, but breaks the udeps check.

@LucioFranco
Copy link
Member

Ok I went ahead and fixed this here #2432

LucioFranco added a commit that referenced this pull request Oct 21, 2025
Reference #2431

---------

Co-authored-by: Ivan Babrou <github@ivan.computer>
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants