est31 / warnalyzer

Show unused code from multi-crate Rust projects
Other
89 stars 4 forks source link

Try on rustc #2

Closed bjorn3 closed 3 years ago

bjorn3 commented 5 years ago

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

est31 commented 5 years ago

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 commented 5 years ago

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

:)

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

Thanks!

bjorn3 commented 5 years ago
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
est31 commented 3 years ago

https://github.com/rust-lang/rust/pull/77739 is merged, closing.