Skip to content

Commit 1ba7b4e

Browse files
committed
Auto merge of #65630 - ecstatic-morse:graphviz-tidy, r=Mark-Simulacrum
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 also tells git to ignore DOT files in the root or the `mir_dump` directory, which `-Z dump-mir` uses by default. This will prevent #65071 from occurring again. It needs to be merged after #65629, otherwise `tidy` will start failing. r? @Mark-Simulacrum
2 parents 770b9e3 + efcae57 commit 1ba7b4e

File tree

4 files changed

+29
-0
lines changed

4 files changed

+29
-0
lines changed

.gitignore

+3
Original file line numberDiff line numberDiff line change
@@ -52,3 +52,6 @@ config.stamp
5252
Session.vim
5353
.cargo
5454
no_llvm_build
55+
# Generated when dumping Graphviz output for debugging:
56+
/mir_dump/
57+
/*.dot

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)