Skip to content

Commit ace641c

Browse files
committed
Migrate the unstable_book check to diagnostics
1 parent 1c12747 commit ace641c

File tree

2 files changed

+19
-23
lines changed

2 files changed

+19
-23
lines changed

src/tools/tidy/src/main.rs

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -169,7 +169,7 @@ fn main() {
169169
verbose,
170170
)
171171
};
172-
// check!(unstable_book, &src_path, collected);
172+
check!(unstable_book, &src_path, collected);
173173
//
174174
// check!(
175175
// extra_checks,

src/tools/tidy/src/unstable_book.rs

Lines changed: 18 additions & 22 deletions
Original file line numberDiff line numberDiff line change
@@ -2,6 +2,7 @@ use std::collections::BTreeSet;
22
use std::fs;
33
use std::path::{Path, PathBuf};
44

5+
use crate::diagnostics::{DiagCtx, RunningCheck};
56
use crate::features::{CollectedFeatures, Features, Status};
67

78
pub const PATH_STR: &str = "doc/unstable-book";
@@ -75,19 +76,18 @@ fn collect_unstable_book_lib_features_section_file_names(base_src_path: &Path) -
7576
}
7677

7778
/// Would switching underscores for dashes work?
78-
fn maybe_suggest_dashes(names: &BTreeSet<String>, feature_name: &str, bad: &mut bool) {
79+
fn maybe_suggest_dashes(names: &BTreeSet<String>, feature_name: &str, check: &mut RunningCheck) {
7980
let with_dashes = feature_name.replace('_', "-");
8081
if names.contains(&with_dashes) {
81-
tidy_error!(
82-
bad,
83-
"the file `{}.md` contains underscores; use dashes instead: `{}.md`",
84-
feature_name,
85-
with_dashes,
86-
);
82+
check.error(format!(
83+
"the file `{feature_name}.md` contains underscores; use dashes instead: `{with_dashes}.md`",
84+
));
8785
}
8886
}
8987

90-
pub fn check(path: &Path, features: CollectedFeatures, bad: &mut bool) {
88+
pub fn check(path: &Path, features: CollectedFeatures, diag_ctx: DiagCtx) {
89+
let mut check = diag_ctx.start_check("unstable_book");
90+
9191
let lang_features = features.lang;
9292
let lib_features = features
9393
.lib
@@ -108,26 +108,22 @@ pub fn check(path: &Path, features: CollectedFeatures, bad: &mut bool) {
108108
// Check for Unstable Book sections that don't have a corresponding unstable feature
109109
for feature_name in &unstable_book_lib_features_section_file_names - &unstable_lib_feature_names
110110
{
111-
tidy_error!(
112-
bad,
113-
"The Unstable Book has a 'library feature' section '{}' which doesn't \
114-
correspond to an unstable library feature",
115-
feature_name
116-
);
117-
maybe_suggest_dashes(&unstable_lib_feature_names, &feature_name, bad);
111+
check.error(format!(
112+
"The Unstable Book has a 'library feature' section '{feature_name}' which doesn't \
113+
correspond to an unstable library feature"
114+
));
115+
maybe_suggest_dashes(&unstable_lib_feature_names, &feature_name, &mut check);
118116
}
119117

120118
// Check for Unstable Book sections that don't have a corresponding unstable feature.
121119
for feature_name in
122120
&unstable_book_lang_features_section_file_names - &unstable_lang_feature_names
123121
{
124-
tidy_error!(
125-
bad,
126-
"The Unstable Book has a 'language feature' section '{}' which doesn't \
127-
correspond to an unstable language feature",
128-
feature_name
129-
);
130-
maybe_suggest_dashes(&unstable_lang_feature_names, &feature_name, bad);
122+
check.error(format!(
123+
"The Unstable Book has a 'language feature' section '{feature_name}' which doesn't \
124+
correspond to an unstable language feature"
125+
));
126+
maybe_suggest_dashes(&unstable_lang_feature_names, &feature_name, &mut check);
131127
}
132128

133129
// List unstable features that don't have Unstable Book sections.

0 commit comments

Comments
 (0)