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

Trim crate graph #124648

Merged
merged 4 commits into from
May 4, 2024
Merged

Trim crate graph #124648

merged 4 commits into from
May 4, 2024

Conversation

nnethercote
Copy link
Contributor

This PR removes some unnecessary Cargo.toml entries, and makes some other small related cleanups that I found while looking at this stuff.

r? @pnkfelix

I found these with a hacky shell script.
There are a few common abbreviations like `use rustc_ast as ast` and
`use rust_hir as hir` for names that are used a lot. But there are also
some cases where a crate is renamed just once in the whole codebase, and
that ends up making things harder to read rather than easier. This
commit removes them.
This is a case where `rustc_parse_format` is renamed as `parse` but a
couple of places don't take advantage.
@rustbot rustbot added A-query-system Area: The rustc query system (https://rustc-dev-guide.rust-lang.org/query.html) 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. labels May 3, 2024
@rustbot
Copy link
Collaborator

rustbot commented May 3, 2024

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.

@jackh726
Copy link
Member

jackh726 commented May 3, 2024

Would it be possible (and useful?) to have a tidy lint that looks for unused dependencies in the cargo.toml?

@jackh726
Copy link
Member

jackh726 commented May 3, 2024

r? jackh726

@bors r+

@bors
Copy link
Contributor

bors commented May 3, 2024

📌 Commit a503893 has been approved by jackh726

It is now in the queue for this repository.

@rustbot rustbot assigned jackh726 and unassigned pnkfelix May 3, 2024
@bors bors added S-waiting-on-bors Status: Waiting on bors to run and complete tests. Bors will change the label on completion. and removed S-waiting-on-review Status: Awaiting review from the assignee but also interested parties. labels May 3, 2024
@nnethercote
Copy link
Contributor Author

nnethercote commented May 3, 2024

Would it be possible (and useful?) to have a tidy lint that looks for unused dependencies in the cargo.toml?

Yes!

One tricky case that comes up a lot is when a proc macro expansion contains a reference to a crate that isn't otherwise mentioned. E.g. any derived Encoder/Decoder impl mandates the use of rustc_serialize, but rust_serialize doesn't show up anywhere in the code.

compiler-errors added a commit to compiler-errors/rust that referenced this pull request May 4, 2024
…ckh726

Trim crate graph

This PR removes some unnecessary `Cargo.toml` entries, and makes some other small related cleanups that I found while looking at this stuff.

r? `@pnkfelix`
bors added a commit to rust-lang-ci/rust that referenced this pull request May 4, 2024
…mpiler-errors

Rollup of 8 pull requests

Successful merges:

 - rust-lang#124293 (Let miri and const eval execute intrinsics' fallback bodies)
 - rust-lang#124418 (Use a proof tree visitor to refine the `Obligation` for error reporting in new solver)
 - rust-lang#124480 (Change `SIGPIPE` ui from `#[unix_sigpipe = "..."]` to `-Zon-broken-pipe=...`)
 - rust-lang#124648 (Trim crate graph)
 - rust-lang#124656 (release notes 1.78: add link to interior-mut breaking change)
 - rust-lang#124658 (Migrate `run-make/doctests-keep-binaries` to new rmake.rs format)
 - rust-lang#124681 (zkvm: fix run_tests)
 - rust-lang#124687 (Make `Bounds.clauses` private)

r? `@ghost`
`@rustbot` modify labels: rollup
compiler-errors added a commit to compiler-errors/rust that referenced this pull request May 4, 2024
…ckh726

Trim crate graph

This PR removes some unnecessary `Cargo.toml` entries, and makes some other small related cleanups that I found while looking at this stuff.

r? ``@pnkfelix``
bors added a commit to rust-lang-ci/rust that referenced this pull request May 4, 2024
…mpiler-errors

Rollup of 8 pull requests

Successful merges:

 - rust-lang#124418 (Use a proof tree visitor to refine the `Obligation` for error reporting in new solver)
 - rust-lang#124480 (Change `SIGPIPE` ui from `#[unix_sigpipe = "..."]` to `-Zon-broken-pipe=...`)
 - rust-lang#124648 (Trim crate graph)
 - rust-lang#124656 (release notes 1.78: add link to interior-mut breaking change)
 - rust-lang#124658 (Migrate `run-make/doctests-keep-binaries` to new rmake.rs format)
 - rust-lang#124678 (Stabilize `split_at_checked`)
 - rust-lang#124681 (zkvm: fix run_tests)
 - rust-lang#124687 (Make `Bounds.clauses` private)

r? `@ghost`
`@rustbot` modify labels: rollup
@bors bors merged commit 356b6c7 into rust-lang:master May 4, 2024
6 checks passed
@rustbot rustbot added this to the 1.80.0 milestone May 4, 2024
rust-timer added a commit to rust-lang-ci/rust that referenced this pull request May 4, 2024
Rollup merge of rust-lang#124648 - nnethercote:trim-crate-graph, r=jackh726

Trim crate graph

This PR removes some unnecessary `Cargo.toml` entries, and makes some other small related cleanups that I found while looking at this stuff.

r? ```@pnkfelix```
@nnethercote nnethercote deleted the trim-crate-graph branch May 5, 2024 22:21
@nnethercote
Copy link
Contributor Author

For posterity, here is the script I used.

#! /bin/sh
#
# For each `rustc_*` crate, look for other `rustc_*` crates mentioned in
# `Cargo.toml` and count how many times the crate name appears. Crates with
# zero counts might be removable as dependencies.

# False positives, i.e. cases reported as 0 uses but are actually needed:
# - `rustc_use_parallel_compiler` is a feature that looks like a crate.
# - `rustc_serialize` and several other crates are mentioned only in expanded
#   derive macros.
# - Some crates (e.g `rustc_ast_ir`) have a `nightly` feature that lists
#   crates, which I don't understand.

for crate in compiler/rustc_* ; do
    echo "---------------------------------------"
    echo "-- $crate --"
    echo "---------------------------------------"
    cd $crate
    deps=`grep "^rustc_" Cargo.toml | sed 's/ .*//'`
    for dep in $deps ; do
        count=`git grep "\<$dep\>" | grep -v Cargo.toml | wc -l`
        printf "%25s %s\n" $dep $count
    done
    echo
    cd ../..
done

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) S-waiting-on-bors Status: Waiting on bors to run and complete tests. Bors will change the label on completion. T-compiler Relevant to the compiler team, which will review and decide on the PR/issue.
Projects
None yet
Development

Successfully merging this pull request may close these issues.

5 participants