Skip to content

Commit

Permalink
Collect at callsite, use eprintln instead of println
Browse files Browse the repository at this point in the history
  • Loading branch information
phansch committed May 17, 2019
1 parent d9a8a8a commit 619a290
Showing 1 changed file with 3 additions and 4 deletions.
7 changes: 3 additions & 4 deletions clippy_dev/src/stderr_length_check.rs
Original file line number Diff line number Diff line change
Expand Up @@ -11,18 +11,18 @@ const LIMIT: usize = 320;

pub fn check() {
let stderr_files = stderr_files();
let exceeding_files = exceeding_stderr_files(stderr_files);
let exceeding_files = exceeding_stderr_files(stderr_files).collect::<Vec<String>>();

if !exceeding_files.is_empty() {
println!("Error: stderr files exceeding limit of {} lines:", LIMIT);
eprintln!("Error: stderr files exceeding limit of {} lines:", LIMIT);
for path in exceeding_files {
println!("{}", path);
}
std::process::exit(1);
}
}

fn exceeding_stderr_files(files: impl Iterator<Item = walkdir::DirEntry>) -> Vec<String> {
fn exceeding_stderr_files(files: impl Iterator<Item = walkdir::DirEntry>) -> impl Iterator<Item = String> {
files
.filter_map(|file| {
let path = file.path().to_str().expect("Could not convert path to str").to_string();
Expand All @@ -33,7 +33,6 @@ fn exceeding_stderr_files(files: impl Iterator<Item = walkdir::DirEntry>) -> Vec
None
}
})
.collect()
}

fn stderr_files() -> impl Iterator<Item = walkdir::DirEntry> {
Expand Down

0 comments on commit 619a290

Please sign in to comment.