33
44use std:: path:: Path ;
55
6- pub fn check ( librustdoc_path : & Path , bad : & mut bool ) {
6+ use crate :: diagnostics:: { CheckId , DiagCtx , RunningCheck } ;
7+
8+ pub fn check ( librustdoc_path : & Path , diag_ctx : DiagCtx ) {
9+ let mut check = diag_ctx. start_check ( CheckId :: new ( "rustdoc_css_themes" ) . path ( librustdoc_path) ) ;
10+
711 let rustdoc_css = "html/static/css/rustdoc.css" ;
812 let noscript_css = "html/static/css/noscript.css" ;
913 let rustdoc_css_contents = std:: fs:: read_to_string ( librustdoc_path. join ( rustdoc_css) )
@@ -14,21 +18,21 @@ pub fn check(librustdoc_path: &Path, bad: &mut bool) {
1418 "light" ,
1519 rustdoc_css_contents. lines ( ) . enumerate ( ) . map ( |( i, l) | ( i + 1 , l. trim ( ) ) ) ,
1620 noscript_css_contents. lines ( ) . enumerate ( ) . map ( |( i, l) | ( i + 1 , l. trim ( ) ) ) ,
17- bad ,
21+ & mut check ,
1822 ) ;
1923 compare_themes_from_files (
2024 "dark" ,
2125 rustdoc_css_contents. lines ( ) . enumerate ( ) ,
2226 noscript_css_contents. lines ( ) . enumerate ( ) ,
23- bad ,
27+ & mut check ,
2428 ) ;
2529}
2630
2731fn compare_themes_from_files < ' a > (
2832 name : & str ,
2933 mut rustdoc_css_lines : impl Iterator < Item = ( usize , & ' a str ) > ,
3034 mut noscript_css_lines : impl Iterator < Item = ( usize , & ' a str ) > ,
31- bad : & mut bool ,
35+ check : & mut RunningCheck ,
3236) {
3337 let begin_theme_pat = format ! ( "/* Begin theme: {name}" ) ;
3438 let mut found_theme = None ;
@@ -38,10 +42,9 @@ fn compare_themes_from_files<'a>(
3842 continue ;
3943 }
4044 if let Some ( found_theme) = found_theme {
41- tidy_error ! (
42- bad,
45+ check. error ( format ! (
4346 "rustdoc.css contains two {name} themes on lines {rustdoc_css_line_number} and {found_theme}" ,
44- ) ;
47+ ) ) ;
4548 return ;
4649 }
4750 found_theme = Some ( rustdoc_css_line_number) ;
@@ -50,14 +53,13 @@ fn compare_themes_from_files<'a>(
5053 continue ;
5154 }
5255 if let Some ( found_theme_noscript) = found_theme_noscript {
53- tidy_error ! (
54- bad,
56+ check. error ( format ! (
5557 "noscript.css contains two {name} themes on lines {noscript_css_line_number} and {found_theme_noscript}" ,
56- ) ;
58+ ) ) ;
5759 return ;
5860 }
5961 found_theme_noscript = Some ( noscript_css_line_number) ;
60- compare_themes ( name, & mut rustdoc_css_lines, & mut noscript_css_lines, bad ) ;
62+ compare_themes ( name, & mut rustdoc_css_lines, & mut noscript_css_lines, check ) ;
6163 }
6264 }
6365}
@@ -66,7 +68,7 @@ fn compare_themes<'a>(
6668 name : & str ,
6769 rustdoc_css_lines : impl Iterator < Item = ( usize , & ' a str ) > ,
6870 noscript_css_lines : impl Iterator < Item = ( usize , & ' a str ) > ,
69- bad : & mut bool ,
71+ check : & mut RunningCheck ,
7072) {
7173 let end_theme_pat = format ! ( "/* End theme: {name}" ) ;
7274 for (
@@ -90,12 +92,11 @@ fn compare_themes<'a>(
9092 break ;
9193 }
9294 if rustdoc_css_line != noscript_css_line {
93- tidy_error ! (
94- bad,
95- "noscript.css:{noscript_css_line_number} and rustdoc.css:{rustdoc_css_line_number} contain copies of {name} theme that are not the same" ,
96- ) ;
97- eprintln ! ( "- {noscript_css_line}" ) ;
98- eprintln ! ( "+ {rustdoc_css_line}" ) ;
95+ check. error ( format ! (
96+ r#"noscript.css:{noscript_css_line_number} and rustdoc.css:{rustdoc_css_line_number} contain copies of {name} theme that are not the same
97+ - {noscript_css_line}
98+ + {rustdoc_css_line}"# ,
99+ ) ) ;
99100 return ;
100101 }
101102 }
0 commit comments