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

Try on rustc #2

Closed
bjorn3 opened this issue Jul 10, 2019 · 4 comments · Fixed by rust-lang/rust#77739
Closed

Try on rustc #2

bjorn3 opened this issue Jul 10, 2019 · 4 comments · Fixed by rust-lang/rust#77739

Comments

@bjorn3
Copy link

bjorn3 commented Jul 10, 2019

Might be fun to find out how much of rustc is actually unused.

@est31
Copy link
Owner

est31 commented Jul 10, 2019

Thanks for your interest in warnalyzer!

Rustc is definitely one of the targets. You need to watch out though because projects like clippy use rustc as well. Also, there are a few bugs in save-analysis generation in rustc which create tons of false positives (see readme). So be ready for the main job being filtering out of false positives :). Someone familiar with rustc using warnalyzer is a very great idea as this increases the chances of those bugs fixed dramatically :p.

You could probably add the save-analysis flag somewhere in rustbuild's rustc wrapper and build stage0 compiler artifacts with it. Then point warnalyzer at the rustc binary crate.

If you need any help, I'm right there.

@bjorn3
Copy link
Author

bjorn3 commented Jul 11, 2019

So be ready for the main job being filtering out of false positives :)

:)

If you need any help, I'm right there.

Thanks!

@bjorn3
Copy link
Author

bjorn3 commented Aug 15, 2019

rust $ git diff
diff --git a/src/bootstrap/bin/rustc.rs b/src/bootstrap/bin/rustc.rs
index 9c01de8aa8..bea1f21272 100644
--- a/src/bootstrap/bin/rustc.rs
+++ b/src/bootstrap/bin/rustc.rs
@@ -45,6 +45,9 @@ fn main() {
         }
     }
 
+
+    args.push("-Zsave-analysis".into());
+
     // Detect whether or not we're a build script depending on whether --target
     // is passed (a bit janky...)
     let target = args.windows(2)
rust $ ./x.py check
rust $ cd ../warnalyzer
warnalyzer $ cargo run ../rust/build/x86_64-*/stage0-rustc/x86_64-*/release/deps/save-analysis/rustc_binary-*.json | wc -l
2612

JohnTitor added a commit to JohnTitor/rust that referenced this issue Oct 14, 2020
…enkov,varkor

Remove unused code

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](https://github.com/est31/warnalyzer) to detect unused items in a cross-crate setting.

Closes est31/warnalyzer#2
@est31
Copy link
Owner

est31 commented Oct 16, 2020

rust-lang/rust#77739 is merged, closing.

@est31 est31 closed this as completed Oct 16, 2020
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 a pull request may close this issue.

2 participants