Skip to content

Commit 6f4e724

Browse files
committed
Migrate the rustdoc_templates check to diagnostics
1 parent 9cf485b commit 6f4e724

File tree

2 files changed

+9
-8
lines changed

2 files changed

+9
-8
lines changed

src/tools/tidy/src/main.rs

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -112,7 +112,7 @@ fn main() {
112112
check!(mir_opt_tests, &tests_path, bless);
113113
check!(rustdoc_gui_tests, &tests_path);
114114
check!(rustdoc_css_themes, &librustdoc_path);
115-
// check!(rustdoc_templates, &librustdoc_path);
115+
check!(rustdoc_templates, &librustdoc_path);
116116
// check!(rustdoc_json, &src_path, &ci_info);
117117
check!(known_bug, &crashes_path);
118118
check!(unknown_revision, &tests_path);

src/tools/tidy/src/rustdoc_templates.rs

Lines changed: 8 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -6,12 +6,15 @@ use std::path::Path;
66

77
use ignore::DirEntry;
88

9+
use crate::diagnostics::{CheckId, DiagCtx};
910
use crate::walk::walk;
1011

1112
// Array containing `("beginning of tag", "end of tag")`.
1213
const TAGS: &[(&str, &str)] = &[("{#", "#}"), ("{%", "%}"), ("{{", "}}")];
1314

14-
pub fn check(librustdoc_path: &Path, bad: &mut bool) {
15+
pub fn check(librustdoc_path: &Path, diag_ctx: DiagCtx) {
16+
let mut check = diag_ctx.start_check(CheckId::new("rustdoc_templates").path(librustdoc_path));
17+
1518
walk(
1619
&librustdoc_path.join("html/templates"),
1720
|path, is_dir| is_dir || path.extension().is_none_or(|ext| ext != OsStr::new("html")),
@@ -46,12 +49,11 @@ pub fn check(librustdoc_path: &Path, bad: &mut bool) {
4649
})
4750
{
4851
// It seems like ending this line with a jinja tag is not needed after all.
49-
tidy_error!(
50-
bad,
52+
check.error(format!(
5153
"`{}` at line {}: unneeded `{{# #}}` tag at the end of the line",
5254
path.path().display(),
5355
pos + 1,
54-
);
56+
));
5557
}
5658
continue;
5759
}
@@ -67,12 +69,11 @@ pub fn check(librustdoc_path: &Path, bad: &mut bool) {
6769
}) {
6870
None => {
6971
// No it's not, let's error.
70-
tidy_error!(
71-
bad,
72+
check.error(format!(
7273
"`{}` at line {}: missing `{{# #}}` at the end of the line",
7374
path.path().display(),
7475
pos + 1,
75-
);
76+
));
7677
}
7778
Some(end_tag) => {
7879
// We skip the tag.

0 commit comments

Comments
 (0)