Skip to content

Commit c9e361f

Browse files
Check all files in src/test for borrowck_graphviz_postflow
This attribute causes DOT files to be generated in the top-level directory. It is intended to be used only temporarily and should never appear on master. This will prevent #65071 from occurring again.
1 parent c491875 commit c9e361f

File tree

3 files changed

+26
-0
lines changed

3 files changed

+26
-0
lines changed

src/tools/tidy/src/debug_artifacts.rs

+24
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,24 @@
1+
//! Tidy check to prevent creation of unnecessary debug artifacts.
2+
3+
use std::path::{Path, PathBuf};
4+
5+
const GRAPHVIZ_POSTFLOW_MSG: &'static str =
6+
"`borrowck_graphviz_postflow` attribute in test";
7+
8+
pub fn check(path: &Path, bad: &mut bool) {
9+
let test_dir: PathBuf = path.join("test");
10+
11+
super::walk(&test_dir, &mut super::filter_dirs, &mut |entry, contents| {
12+
let filename = entry.path();
13+
let is_rust = filename.extension().map_or(false, |ext| ext == "rs");
14+
if !is_rust {
15+
return;
16+
}
17+
18+
for (i, line) in contents.lines().enumerate() {
19+
if line.contains("borrowck_graphviz_postflow") {
20+
tidy_error!(bad, "{}:{}: {}", filename.display(), i + 1, GRAPHVIZ_POSTFLOW_MSG);
21+
}
22+
}
23+
});
24+
}

src/tools/tidy/src/lib.rs

+1
Original file line numberDiff line numberDiff line change
@@ -31,6 +31,7 @@ macro_rules! tidy_error {
3131

3232
pub mod bins;
3333
pub mod style;
34+
pub mod debug_artifacts;
3435
pub mod errors;
3536
pub mod features;
3637
pub mod cargo;

src/tools/tidy/src/main.rs

+1
Original file line numberDiff line numberDiff line change
@@ -22,6 +22,7 @@ fn main() {
2222
let verbose = args.iter().any(|s| *s == "--verbose");
2323
bins::check(&path, &mut bad);
2424
style::check(&path, &mut bad);
25+
debug_artifacts::check(&path, &mut bad);
2526
errors::check(&path, &mut bad);
2627
cargo::check(&path, &mut bad);
2728
edition::check(&path, &mut bad);

0 commit comments

Comments
 (0)