@@ -48,6 +48,8 @@ fn check_error_code_explanation(
48
48
}
49
49
50
50
fn check_if_error_code_is_test_in_explanation ( f : & str , err_code : & str ) -> bool {
51
+ let mut ignore_found = false ;
52
+
51
53
for line in f. lines ( ) {
52
54
let s = line. trim ( ) ;
53
55
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 {
56
58
if s. starts_with ( "```" ) {
57
59
if s. contains ( "compile_fail" ) && s. contains ( err_code) {
58
60
return true ;
59
- } else if s. contains ( '(' ) {
61
+ } else if s. contains ( "ignore" ) {
60
62
// It's very likely that we can't actually make it fail compilation...
61
- return true ;
63
+ ignore_found = true ;
62
64
}
63
65
}
64
66
}
65
- false
67
+ ignore_found
66
68
}
67
69
68
70
macro_rules! some_or_continue {
@@ -164,18 +166,32 @@ fn extract_error_codes_from_tests(f: &str, error_codes: &mut HashMap<String, boo
164
166
}
165
167
}
166
168
167
- pub fn check ( path : & Path , bad : & mut bool ) {
169
+ pub fn check ( paths : & [ & Path ] , bad : & mut bool ) {
168
170
let mut errors = Vec :: new ( ) ;
171
+ let mut found_explanations = 0 ;
172
+ let mut found_tests = 0 ;
169
173
println ! ( "Checking which error codes lack tests..." ) ;
170
174
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
+ }
179
195
if errors. is_empty ( ) {
180
196
println ! ( "Found {} error codes" , error_codes. len( ) ) ;
181
197
0 commit comments