@@ -48,6 +48,8 @@ fn check_error_code_explanation(
4848}
4949
5050fn check_if_error_code_is_test_in_explanation ( f : & str , err_code : & str ) -> bool {
51+ let mut ignore_found = false ;
52+
5153 for line in f. lines ( ) {
5254 let s = line. trim ( ) ;
5355 if s. starts_with ( "#### Note: this error code is no longer emitted by the compiler" ) {
@@ -56,13 +58,13 @@ fn check_if_error_code_is_test_in_explanation(f: &str, err_code: &str) -> bool {
5658 if s. starts_with ( "```" ) {
5759 if s. contains ( "compile_fail" ) && s. contains ( err_code) {
5860 return true ;
59- } else if s. contains ( '(' ) {
61+ } else if s. contains ( "ignore" ) {
6062 // It's very likely that we can't actually make it fail compilation...
61- return true ;
63+ ignore_found = true ;
6264 }
6365 }
6466 }
65- false
67+ ignore_found
6668}
6769
6870macro_rules! some_or_continue {
@@ -164,18 +166,32 @@ fn extract_error_codes_from_tests(f: &str, error_codes: &mut HashMap<String, boo
164166 }
165167}
166168
167- pub fn check ( path : & Path , bad : & mut bool ) {
169+ pub fn check ( paths : & [ & Path ] , bad : & mut bool ) {
168170 let mut errors = Vec :: new ( ) ;
171+ let mut found_explanations = 0 ;
172+ let mut found_tests = 0 ;
169173 println ! ( "Checking which error codes lack tests..." ) ;
170174 let mut error_codes: HashMap < String , bool > = HashMap :: new ( ) ;
171- super :: walk ( path, & mut |path| super :: filter_dirs ( path) , & mut |entry, contents| {
172- let file_name = entry. file_name ( ) ;
173- if file_name == "error_codes.rs" {
174- extract_error_codes ( contents, & mut error_codes, entry. path ( ) , & mut errors) ;
175- } else if entry. path ( ) . extension ( ) == Some ( OsStr :: new ( "stderr" ) ) {
176- extract_error_codes_from_tests ( contents, & mut error_codes) ;
177- }
178- } ) ;
175+ for path in paths {
176+ super :: walk ( path, & mut |path| super :: filter_dirs ( path) , & mut |entry, contents| {
177+ let file_name = entry. file_name ( ) ;
178+ if file_name == "error_codes.rs" {
179+ extract_error_codes ( contents, & mut error_codes, entry. path ( ) , & mut errors) ;
180+ found_explanations += 1 ;
181+ } else if entry. path ( ) . extension ( ) == Some ( OsStr :: new ( "stderr" ) ) {
182+ extract_error_codes_from_tests ( contents, & mut error_codes) ;
183+ found_tests += 1 ;
184+ }
185+ } ) ;
186+ }
187+ if found_explanations == 0 {
188+ eprintln ! ( "No error code explanation was tested!" ) ;
189+ * bad = true ;
190+ }
191+ if found_tests == 0 {
192+ eprintln ! ( "No error code was found in compilation errors!" ) ;
193+ * bad = true ;
194+ }
179195 if errors. is_empty ( ) {
180196 println ! ( "Found {} error codes" , error_codes. len( ) ) ;
181197
0 commit comments