@@ -2,6 +2,7 @@ use std::collections::BTreeSet;
22use std:: fs;
33use std:: path:: { Path , PathBuf } ;
44
5+ use crate :: diagnostics:: { DiagCtx , RunningCheck } ;
56use crate :: features:: { CollectedFeatures , Features , Status } ;
67
78pub 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