@@ -80,15 +80,6 @@ fn check_if_error_code_is_test_in_explanation(f: &str, err_code: &str) -> bool {
80
80
ignore_found
81
81
}
82
82
83
- macro_rules! some_or_continue {
84
- ( $e: expr) => {
85
- match $e {
86
- Some ( e) => e,
87
- None => continue ,
88
- }
89
- } ;
90
- }
91
-
92
83
fn extract_error_codes (
93
84
f : & str ,
94
85
error_codes : & mut HashMap < String , ErrorCodeStatus > ,
@@ -122,10 +113,16 @@ fn extract_error_codes(
122
113
Some ( ( file_name, _) ) => file_name,
123
114
} ,
124
115
} ;
125
- let path = some_or_continue ! ( path. parent( ) )
116
+
117
+ let Some ( parent) = path. parent ( ) else {
118
+ continue ;
119
+ } ;
120
+
121
+ let path = parent
126
122
. join ( md_file_name)
127
123
. canonicalize ( )
128
124
. expect ( "failed to canonicalize error explanation file path" ) ;
125
+
129
126
match read_to_string ( & path) {
130
127
Ok ( content) => {
131
128
let has_test = check_if_error_code_is_test_in_explanation ( & content, & err_code) ;
@@ -215,8 +212,6 @@ pub fn check(paths: &[&Path], bad: &mut bool) {
215
212
// * #[error = "E0111"]
216
213
let regex = Regex :: new ( r#"[(,"\s](E\d{4})[,)"]"# ) . unwrap ( ) ;
217
214
218
- println ! ( "Checking which error codes lack tests..." ) ;
219
-
220
215
for path in paths {
221
216
walk ( path, & mut filter_dirs, & mut |entry, contents| {
222
217
let file_name = entry. file_name ( ) ;
@@ -245,20 +240,15 @@ pub fn check(paths: &[&Path], bad: &mut bool) {
245
240
} ) ;
246
241
}
247
242
if found_explanations == 0 {
248
- eprintln ! ( "No error code explanation was tested!" ) ;
249
- * bad = true ;
243
+ tidy_error ! ( bad, "No error code explanation was tested!" ) ;
250
244
}
251
245
if found_tests == 0 {
252
- eprintln ! ( "No error code was found in compilation errors!" ) ;
253
- * bad = true ;
246
+ tidy_error ! ( bad, "No error code was found in compilation errors!" ) ;
254
247
}
255
248
if explanations. is_empty ( ) {
256
- eprintln ! ( "No error code explanation was found!" ) ;
257
- * bad = true ;
249
+ tidy_error ! ( bad, "No error code explanation was found!" ) ;
258
250
}
259
251
if errors. is_empty ( ) {
260
- println ! ( "Found {} error codes" , error_codes. len( ) ) ;
261
-
262
252
for ( err_code, error_status) in & error_codes {
263
253
if !error_status. has_test && !EXEMPTED_FROM_TEST . contains ( & err_code. as_str ( ) ) {
264
254
errors. push ( format ! ( "Error code {err_code} needs to have at least one UI test!" ) ) ;
@@ -310,11 +300,6 @@ pub fn check(paths: &[&Path], bad: &mut bool) {
310
300
}
311
301
errors. sort ( ) ;
312
302
for err in & errors {
313
- eprintln ! ( "{err}" ) ;
314
- }
315
- println ! ( "Found {} error(s) in error codes" , errors. len( ) ) ;
316
- if !errors. is_empty ( ) {
317
- * bad = true ;
303
+ tidy_error ! ( bad, "{err}" ) ;
318
304
}
319
- println ! ( "Done!" ) ;
320
305
}
0 commit comments