Skip to content

Commit 028692b

Browse files
committed
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.
1 parent 8f1cceb commit 028692b

File tree

1 file changed

+24
-1
lines changed

1 file changed

+24
-1
lines changed

clippy_dev/src/lintcheck.rs

Lines changed: 24 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -225,13 +225,36 @@ impl Crate {
225225
let warnings: Vec<ClippyWarning> = output_lines
226226
.into_iter()
227227
// get all clippy warnings and ICEs
228-
.filter(|line| line.contains("clippy::") || line.contains("internal compiler error: "))
228+
.filter(|line| filter_clippy_warnings(&line))
229229
.map(|json_msg| parse_json_message(json_msg, &self))
230230
.collect();
231231
warnings
232232
}
233233
}
234234

235+
/// takes a single json-formatted clippy warnings and returns true (we are interested in that line)
236+
/// or false (we aren't)
237+
fn filter_clippy_warnings(line: &str) -> bool {
238+
// we want to collect ICEs because clippy might have crashed.
239+
// these are summarized later
240+
if line.contains("internal compiler error: ") {
241+
return true;
242+
}
243+
// in general, we want all clippy warnings
244+
// however due to some kind of bug, sometimes there are absolute paths
245+
// to libcore files inside the message
246+
// or we end up with cargo-metadata output (https://github.com/rust-lang/rust-clippy/issues/6508)
247+
248+
// filter out these message to avoid unnecessary noise in the logs
249+
if line.contains("clippy::")
250+
&& !(line.contains("could not read cargo metadata")
251+
|| (line.contains(".rustup") && line.contains("toolchains")))
252+
{
253+
return true;
254+
}
255+
false
256+
}
257+
235258
/// Builds clippy inside the repo to make sure we have a clippy executable we can use.
236259
fn build_clippy() {
237260
Command::new("cargo")

0 commit comments

Comments
 (0)