tidy/
debug_artifacts.rs

1//! Tidy check to prevent creation of unnecessary debug artifacts while running tests.
2
3use std::path::Path;
4
5use crate::diagnostics::{CheckId, DiagCtx};
6use crate::walk::{filter_dirs, filter_not_rust, walk};
7
8const GRAPHVIZ_POSTFLOW_MSG: &str = "`borrowck_graphviz_postflow` attribute in test";
9
10pub fn check(test_dir: &Path, diag_ctx: DiagCtx) {
11    let mut check = diag_ctx.start_check(CheckId::new("debug_artifacts").path(test_dir));
12
13    walk(
14        test_dir,
15        |path, _is_dir| filter_dirs(path) || filter_not_rust(path),
16        &mut |entry, contents| {
17            for (i, line) in contents.lines().enumerate() {
18                if line.contains("borrowck_graphviz_postflow") {
19                    check.error(format!(
20                        "{}:{}: {GRAPHVIZ_POSTFLOW_MSG}",
21                        entry.path().display(),
22                        i + 1
23                    ));
24                }
25            }
26        },
27    );
28}