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

Remove unused code #77739

Merged
merged 8 commits into from
Oct 15, 2020
Merged

Remove unused code #77739

merged 8 commits into from
Oct 15, 2020

Conversation

est31
Copy link
Member

@est31 est31 commented Oct 9, 2020

Rustc has a builtin lint for detecting unused code inside a crate, but when an item is marked pub, the code, even if unused inside the entire workspace, is never marked as such. Therefore, I've built warnalyzer to detect unused items in a cross-crate setting.

Closes est31/warnalyzer#2

@rust-highfive
Copy link
Collaborator

r? @varkor

(rust_highfive has picked a reviewer for you, use r? to override)

@rust-highfive rust-highfive added the S-waiting-on-review Status: Awaiting review from the assignee but also interested parties. label Oct 9, 2020
@est31
Copy link
Member Author

est31 commented Oct 9, 2020

See also #77740

@est31 est31 force-pushed the remove_unused_code branch 3 times, most recently from 52512cd to ed0d9fc Compare October 9, 2020 10:43
@est31
Copy link
Member Author

est31 commented Oct 9, 2020

Network hickup.

@bors retry

@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 Oct 9, 2020
@est31
Copy link
Member Author

est31 commented Oct 9, 2020

Nevermind, wrong PR. Meant #77690 instead.

@petrochenkov
Copy link
Contributor

r=me on everything in rustc_(ast,errors,expand,hir,hir_pretty,lint,metadata,parse,session,span).

I'd suggest to make sure this doesn't break clippy/rls/etc though, by doing textual search on the repo (together with all the submodules) for the removed entities.

@petrochenkov petrochenkov added S-waiting-on-review Status: Awaiting review from the assignee but also interested parties. and removed S-waiting-on-bors Status: Waiting on bors to run and complete tests. Bors will change the label on completion. labels Oct 9, 2020
@est31
Copy link
Member Author

est31 commented Oct 10, 2020

I'd suggest to make sure this doesn't break clippy/rls/etc though, by doing textual search on the repo (together with all the submodules) for the removed entities.

I made a textual search for most things, yes, already because warnalyzer has tons of false positives. As a result, some things I didn't include in this PR. Some names are highly non-unique though, so I didn't verify it with a search for all of them.

To be really sure, I just enabled extended = true in config.toml and did an x.py build --stage 1 to compile all the tools. It all works fine.

Copy link
Member

@varkor varkor left a comment

Choose a reason for hiding this comment

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

Most of the other changes look fine to me, though I would prefer a second pair of eyes on the rustc_middle/src/mir changes just to double-check.
cc @oli-obk @RalfJung

compiler/rustc_middle/src/ty/fold.rs Outdated Show resolved Hide resolved
@RalfJung
Copy link
Member

Most of the other changes look fine to me, though I would prefer a second pair of eyes on the rustc_middle/src/mir changes just to double-check.

I checked the changes in interpret; I cannot really comment on the wider MIR module. Not sure if Oli has plans for those const convenience methods that are being removed here, or if they are old cruft.

@est31 est31 force-pushed the remove_unused_code branch from ed0d9fc to 439f2d6 Compare October 10, 2020 14:44
@varkor
Copy link
Member

varkor commented Oct 12, 2020

I think this looks good to merge once the Direction enum has been removed!

@bors
Copy link
Contributor

bors commented Oct 12, 2020

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

Note that reviewers usually do not review pull requests until merge conflicts are resolved! Once you resolve the conflicts, you should change the labels applied by bors to indicate that your PR is ready for review. Post this as a comment to change the labels:

@rustbot modify labels: +S-waiting-on-review -S-waiting-on-author

@est31 est31 force-pushed the remove_unused_code branch from 439f2d6 to fc30e7e Compare October 13, 2020 05:17
@bors
Copy link
Contributor

bors commented Oct 14, 2020

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

Note that reviewers usually do not review pull requests until merge conflicts are resolved! Once you resolve the conflicts, you should change the labels applied by bors to indicate that your PR is ready for review. Post this as a comment to change the labels:

@rustbot modify labels: +S-waiting-on-review -S-waiting-on-author

@est31 est31 force-pushed the remove_unused_code branch from fc30e7e to 215cd36 Compare October 14, 2020 02:14
@est31
Copy link
Member Author

est31 commented Oct 14, 2020

@varkor it's ready for review.

@rustbot modify labels: +S-waiting-on-review -S-waiting-on-author

@@ -467,23 +462,6 @@ impl Generics<'hir> {
}
}

pub fn own_counts(&self) -> GenericParamCount {
Copy link
Member

Choose a reason for hiding this comment

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

Ah, I'm glad to see this go.

@varkor
Copy link
Member

varkor commented Oct 14, 2020

@bors r=petrochenkov,varkor

@bors
Copy link
Contributor

bors commented Oct 14, 2020

📌 Commit 215cd36 has been approved by petrochenkov,varkor

@bors
Copy link
Contributor

bors commented Oct 14, 2020

🌲 The tree is currently closed for pull requests below priority 100, this pull request will be tested once the tree is reopened

@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 Oct 14, 2020
bors added a commit to rust-lang-ci/rust that referenced this pull request Oct 14, 2020
Rollup of 9 pull requests

Successful merges:

 - rust-lang#77570 (Allow ascii whitespace char for doc aliases )
 - rust-lang#77739 (Remove unused code)
 - rust-lang#77753 (Check html comments)
 - rust-lang#77879 (Provide better documentation and help messages for x.py setup)
 - rust-lang#77902 (Include aarch64-pc-windows-msvc in the dist manifests)
 - rust-lang#77934 (Document -Z codegen-backend in the unstable book)
 - rust-lang#77936 (Remove needless alloc_slice)
 - rust-lang#77946 (Validate references to source scopes)
 - rust-lang#77951 (Update books)

Failed merges:

r? `@ghost`
@bors bors merged commit 022d207 into rust-lang:master Oct 15, 2020
@rustbot rustbot added this to the 1.49.0 milestone Oct 15, 2020
@est31 est31 mentioned this pull request Oct 16, 2020
@jyn514 jyn514 mentioned this pull request Mar 16, 2021
6 tasks
bors added a commit to rust-lang-ci/rust that referenced this pull request Mar 29, 2021
Remove (lots of) dead code

Builds on
- [ ] rust-lang#83161
- [x] rust-lang#83230
- [x] rust-lang#83197.

Found with https://github.com/est31/warnalyzer.
See rust-lang#77739 for a similar change in the past.

Dubious changes:
- Maybe some of the dead code in rustc_data_structures should be kept, in case someone wants to use it in the future?

TODO:
- [ ] check if any of the comments on the deleted code should be kept.
- [x] update the compiler documentation; right now it fails to build
- [x] finish moving `cfg(test)` changes into rust-lang#83197

cc `@est31`
spikespaz pushed a commit to spikespaz/dotwalk-rs that referenced this pull request Aug 29, 2024
Remove (lots of) dead code

Builds on
- [ ] rust-lang/rust#83161
- [x] rust-lang/rust#83230
- [x] rust-lang/rust#83197.

Found with https://github.com/est31/warnalyzer.
See rust-lang/rust#77739 for a similar change in the past.

Dubious changes:
- Maybe some of the dead code in rustc_data_structures should be kept, in case someone wants to use it in the future?

TODO:
- [ ] check if any of the comments on the deleted code should be kept.
- [x] update the compiler documentation; right now it fails to build
- [x] finish moving `cfg(test)` changes into rust-lang/rust#83197

cc `@est31`
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
S-waiting-on-bors Status: Waiting on bors to run and complete tests. Bors will change the label on completion.
Projects
None yet
Development

Successfully merging this pull request may close these issues.

Try on rustc
10 participants