about summary refs log tree commit diff
path: root/clippy_dev
diff options
context:
space:
mode:
authorMatthias Krüger <matthias.krueger@famsik.de>2021-02-15 23:13:41 +0100
committerMatthias Krüger <matthias.krueger@famsik.de>2021-02-15 23:38:50 +0100
commit028692b46a52f2fe63e7ed18bb4f46ab83cdcb8c (patch)
tree79ad37ad0ad0af3ee035f43853595db566452b5a /clippy_dev
parent8f1cceb6ffe1324d403702e2ccf48d96a74eb33b (diff)
downloadrust-028692b46a52f2fe63e7ed18bb4f46ab83cdcb8c.tar.gz
rust-028692b46a52f2fe63e7ed18bb4f46ab83cdcb8c.zip
lintcheck: filter out messages that come from cargo-metadata errors or contain absolute paths to rustc source files
The latter is especially annoying because the paths would change every time we bumped the pinned nightly version.
Diffstat (limited to 'clippy_dev')
-rw-r--r--clippy_dev/src/lintcheck.rs25
1 files changed, 24 insertions, 1 deletions
diff --git a/clippy_dev/src/lintcheck.rs b/clippy_dev/src/lintcheck.rs
index 017d1e09eec..e96e1446c0f 100644
--- a/clippy_dev/src/lintcheck.rs
+++ b/clippy_dev/src/lintcheck.rs
@@ -225,13 +225,36 @@ impl Crate {
         let warnings: Vec<ClippyWarning> = output_lines
             .into_iter()
             // get all clippy warnings and ICEs
-            .filter(|line| line.contains("clippy::") || line.contains("internal compiler error: "))
+            .filter(|line| filter_clippy_warnings(&line))
             .map(|json_msg| parse_json_message(json_msg, &self))
             .collect();
         warnings
     }
 }
 
+/// takes a single json-formatted clippy warnings and returns true (we are interested in that line)
+/// or false (we aren't)
+fn filter_clippy_warnings(line: &str) -> bool {
+    // we want to collect ICEs because clippy might have crashed.
+    // these are summarized later
+    if line.contains("internal compiler error: ") {
+        return true;
+    }
+    // in general, we want all clippy warnings
+    // however due to some kind of bug, sometimes there are absolute paths
+    // to libcore files inside the message
+    // or we end up with cargo-metadata output (https://github.com/rust-lang/rust-clippy/issues/6508)
+
+    // filter out these message to avoid unnecessary noise in the logs
+    if line.contains("clippy::")
+        && !(line.contains("could not read cargo metadata")
+            || (line.contains(".rustup") && line.contains("toolchains")))
+    {
+        return true;
+    }
+    false
+}
+
 /// Builds clippy inside the repo to make sure we have a clippy executable we can use.
 fn build_clippy() {
     Command::new("cargo")