Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Enable deny(unused_crate_dependencies) in all compiler/ crates. #126248

Conversation

nnethercote
Copy link
Contributor

And remove a couple of unused dependencies that this found.

r? @jackh726

And remove a couple of unused dependencies that this found.
@rustbot rustbot added A-query-system Area: The rustc query system (https://rustc-dev-guide.rust-lang.org/query.html) PG-exploit-mitigations Project group: Exploit mitigations S-waiting-on-review Status: Awaiting review from the assignee but also interested parties. T-compiler Relevant to the compiler team, which will review and decide on the PR/issue. WG-trait-system-refactor The Rustc Trait System Refactor Initiative labels Jun 11, 2024
@rustbot
Copy link
Collaborator

rustbot commented Jun 11, 2024

Some changes occurred in exhaustiveness checking

cc @Nadrieril

These commits modify the Cargo.lock file. Unintentional changes to Cargo.lock can be introduced when switching branches and rebasing PRs.

If this was unintentional then you should revert the changes before this PR is merged.
Otherwise, you can ignore this comment.

This PR changes Stable MIR

cc @oli-obk, @celinval, @ouz-a

Some changes occurred in diagnostic error codes

cc @GuillaumeGomez

Some changes occurred to MIR optimizations

cc @rust-lang/wg-mir-opt

Some changes occurred in compiler/rustc_sanitizers

cc @rust-lang/project-exploit-mitigations, @rcvalle

@nnethercote
Copy link
Contributor Author

The false positives mentioned in the FIXME comments are annoying. I started a Zulip thread to ask about that.

@rust-log-analyzer
Copy link
Collaborator

The job mingw-check failed! Check out the build log: (web) (plain)

Click to see the possible cause of the failure (guessed by this bot)
    Checking getrandom v0.2.15
    Checking rustc_data_structures v0.0.0 (/checkout/compiler/rustc_data_structures)
    Checking rand_core v0.6.4
   Compiling thiserror v1.0.61
error: external crate `libc` unused in `rustc_data_structures`: remove the dependency or add `use libc as _;`
note: the lint level is defined here
  --> compiler/rustc_data_structures/src/lib.rs:15:9
   |
15 | #![deny(unused_crate_dependencies)]

@nnethercote
Copy link
Contributor Author

error: external crate `libc` unused in `rustc_data_structures`: remove the dependency or add `use libc as _;`

This error is because libc is used in rustc_data_structures for some platforms (Unix) but not for others (Windows). One way to fix would be to change the Cargo.toml file to list libc as a conditional dependency. The other way would be to add a use libc as _ to the lib.rs file. Not sure which is better. I'm feeling quite ambivalent about this PR overall.

@ChrisDenton
Copy link
Member

One way to fix would be to change the Cargo.toml file to list libc as a conditional dependency. The other way would be to add a use libc as _ to the lib.rs file. Not sure which is better.

On the one hand I do prefer the former but on the other hand I don't really care that much...

@erikdesjardins
Copy link
Contributor

I believe libc usage being removed on Windows was a deliberate change (cc @saethlin), so I'd suggest making it a conditional dependency so no future usages get added.

@saethlin
Copy link
Member

Heh yes I wrote the PR to remove libc on Windows but the idea/motivation was @ChrisDenton.

@bors
Copy link
Contributor

bors commented Jun 12, 2024

☔ The latest upstream changes (presumably #126319) made this pull request unmergeable. Please resolve the merge conflicts.

@jackh726
Copy link
Member

Not sure if this needs a compiler MCP, at the very least, might be worth a team ping.

@nnethercote
Copy link
Contributor Author

Based on the discussion in Zulip I think this lint isn't quite reliable enough to be used en masse like this. Which is a shame. I've filed #126368 for removing a couple more unused dependencies.

@nnethercote nnethercote deleted the add-deny-unused_crate_dependencies branch June 13, 2024 01:47
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
A-query-system Area: The rustc query system (https://rustc-dev-guide.rust-lang.org/query.html) PG-exploit-mitigations Project group: Exploit mitigations S-waiting-on-review Status: Awaiting review from the assignee but also interested parties. T-compiler Relevant to the compiler team, which will review and decide on the PR/issue. WG-trait-system-refactor The Rustc Trait System Refactor Initiative
Projects
None yet
Development

Successfully merging this pull request may close these issues.

8 participants