fix(compile): Where possible, hint about misplaced deps #16940
fix(compile): Where possible, hint about misplaced deps #16940weihanglo merged 10 commits intorust-lang:masterfrom
Conversation
|
r? @ehuss rustbot has assigned @ehuss. Use Why was this reviewer chosen?The reviewer was selected based on:
|
|
The bump check is a non-blocking job currently broken by GitoxideLabs/gitoxide#2541 because cargo-semver-checks isn't able to respect lockfiles fully. |
|
This PR was rebased onto a different master commit. Here's a range-diff highlighting what actually changed. Rebasing is a normal part of keeping PRs up to date, so no action is needed—this note is just to help reviewers. |
| state.seen_units.push(unit.clone()); | ||
| if let Some(existing) = state.unused_externs.as_mut() { | ||
| existing.retain(|ext| unused_externs.contains(ext)); | ||
| } else { | ||
| state.unused_externs = Some(unused_externs); | ||
| } |
There was a problem hiding this comment.
It is a bit weird that the actual core part of this PR is this commit not the fix commit, which people may easily overlook.
The commit message around also doesn't say anything more obvious than "track as we go". It is indeed a refactor commit, though I think it might be worthy adding more context about why this is needed and how this data model unblock the later behavior change.
There was a problem hiding this comment.
I focus PR titles and descriptions on the user-facing impact.
Originally, the intersection was my end-goal. Everything else was "oh, here is another thing I can do". I did not predict at all where it was going to go. I can edit it in hindsight but that also feels weird (wouldn't have been there if I had split the PR like I considered).
I've at least gone into more detail on the commit itself about my intent with it.
Instead of saving off all unused externs and checking the externs against them, let's take the intersection of the unused externs. This makes the logging messages much better for unreported unused externs.
The one side effect is we won't list used export in traces.
Through the re-ordering of things, the check has become redundant and can be removed.
Sometimes a normal dependency is actually a dev-dependency. For any of the dev-dependencies we build, we can let users know that an unused dep might be a misplaced dep.
Update cargo submodule 10 commits in eb9b60f1f6604b5e022c56be31692c215b8ba11d..4f9b52075316e9ced380c8fa492858048d5758b6 2026-04-24 20:52:07 +0000 to 2026-05-01 22:36:41 +0000 - chore(deps): update compatible (rust-lang/cargo#16952) - feat(lints): Add deny-by-default text_direction_codepoint lints (rust-lang/cargo#16950) - chore(deps): update embarkstudios/cargo-deny-action action to v2.0.17 (rust-lang/cargo#16953) - docs(guide): Switch from third-party to first-party unused deps detection (rust-lang/cargo#16946) - Remove curl dependency from crates-io crate (rust-lang/cargo#16936) - chore(deps): update gix to 0.83 (rust-lang/cargo#16945) - fix(compile): Where possible, hint about misplaced deps (rust-lang/cargo#16940) - Remove `windows-sys` from `home` (rust-lang/cargo#16918) - docs(resolver): `--precise <yanked>` is on stable (rust-lang/cargo#16944) - Update `gix` to 0.82 (with security fixes and hardened parsers) (rust-lang/cargo#16941)
What does this PR try to resolve?
Sometimes a normal dependency is actually a dev-dependency.
For any of the dev-dependencies we build, we can let users know that an
unused dep might be a misplaced dep. This check came from #8437 but I originally punted on it due to the complexity of having the right information. Through the refactors done in this, I found it became easy to report this. The help could be improved to show the insertion of the dev-dependency with a removal of the normal dependency but that is being left to a future exercise to limit the scope of this.
This also improves the quality of the logged messages for people who are ok with the false positives that we can't report.
How to test and review this PR?