Skip to content

fix(compile): Ignore unused deps if also transitive #16935

Merged
arlosi merged 3 commits intorust-lang:masterfrom
epage:transitive
Apr 23, 2026
Merged

fix(compile): Ignore unused deps if also transitive #16935
arlosi merged 3 commits intorust-lang:masterfrom
epage:transitive

Conversation

@epage
Copy link
Copy Markdown
Contributor

@epage epage commented Apr 23, 2026

What does this PR try to resolve?

This changes unused_dependencies lint to reduce the chance of false positives while we work out the story of how we want people to response to false positives (rust-lang/rfcs#3920).

How to test and review this PR?

My assumption is that I will revert the ignore lint control added in #16600 after this.

Looking at the known cases of false positives, my short term plan is:

  • transitive version constraint: don't lint
  • transitive feature activation: don't lint
  • dynamically used dep (e.g. build.rs in curl): users must allow

Longer term, I'd like to replace this change with either

We can evolve this because the exact nature of warning-by-default lints is not stable.

epage added 3 commits April 23, 2026 10:24
This is to ensure these tests still have the intended coverage
regardless of how we work around unused direct deps that are present to
control their transitive presence.
This is to reduce false positives without having to ignore them.
In fact, I plan to revert support for `ignore` after this change.
@rustbot rustbot added the S-waiting-on-review Status: Awaiting review from the assignee but also interested parties. label Apr 23, 2026
@rustbot
Copy link
Copy Markdown
Collaborator

rustbot commented Apr 23, 2026

r? @ehuss

rustbot has assigned @ehuss.
They will have a look at your PR within the next two weeks and either review your PR or reassign to another reviewer.

Use r? to explicitly pick a reviewer

Why was this reviewer chosen?

The reviewer was selected based on:

  • Owners of files modified in this PR: @ehuss, @epage, @weihanglo
  • @ehuss, @epage, @weihanglo expanded to ehuss, epage, weihanglo
  • Random selection from ehuss, weihanglo

Copy link
Copy Markdown
Contributor

@arlosi arlosi left a comment

Choose a reason for hiding this comment

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

Makes sense. Thanks!

View changes since this review

@arlosi arlosi added this pull request to the merge queue Apr 23, 2026
Merged via the queue into rust-lang:master with commit 32aa9b5 Apr 23, 2026
29 checks passed
@rustbot rustbot removed the S-waiting-on-review Status: Awaiting review from the assignee but also interested parties. label Apr 23, 2026
pull Bot pushed a commit to Mu-L/cargo that referenced this pull request Apr 23, 2026
This reverts commit b276acc.

This is a follow up to rust-lang#16935 where we take a different direction for
false positives.
Instead of an allowlist, we will ignore unused direct deps that are also
transitive deps (technically still used somewhere).
This leaves workflows like `curl` where the `build.rs` dynamically
decides what deps to use but that seems like enough of an exception case
to not worry about direct integration for.
pull Bot pushed a commit to Mu-L/cargo that referenced this pull request Apr 23, 2026
### What does this PR try to resolve?

This is a follow up to rust-lang#16935 where we take a different direction for
false positives.
We are now ignoring unused direct deps that are also transitive deps
(technically still used somewhere). This leaves workflows like `curl`
where the `build.rs` dynamically decides what deps to use but that seems
like enough of an exception case to not worry about direct integration
for.
This means we can punt on having an allowlist to decide what approach we
want take from among rust-lang/rfcs#3920

### How to test and review this PR?

This reverts commit b276acc.
rust-bors Bot pushed a commit to rust-lang/rust that referenced this pull request Apr 25, 2026
Update cargo submodule

10 commits in 06ac0e7c05770a8c7bbf67bdd12fa1a1eefdc8ae..eb9b60f1f6604b5e022c56be31692c215b8ba11d
2026-04-21 15:33:56 +0000 to 2026-04-24 20:52:07 +0000
- chore: Remove unused deps (rust-lang/cargo#16938)
- feat(compile): Stabilize `build.warnings` (rust-lang/cargo#16796)
- cargo clean: do not error if explicitly specified target-dir does not exist (rust-lang/cargo#16934)
- Revert "feat(lints): Add unused deps ignore list" (rust-lang/cargo#16937)
- fix(compile): Ignore unused deps if also transitive  (rust-lang/cargo#16935)
- Update rustls (rust-lang/cargo#16932)
- chore(deps): update rust crate openssl to v0.10.78 [security] (rust-lang/cargo#16931)
- chore(build-rs): Ensure we lint the crate (rust-lang/cargo#16930)
- Fix flaky test: proc_macro_in_artifact_dep (rust-lang/cargo#16922)
- refactor(compile): Log all ignored unused externs (rust-lang/cargo#16920)

r? ghost
@rustbot rustbot added this to the 1.97.0 milestone Apr 25, 2026
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.

4 participants