@@ -8,15 +8,14 @@ use std::path::Path;
88
99// A few of those error codes can't be tested but all the others can and *should* be tested!
1010const EXEMPTED_FROM_TEST : & [ & str ] = & [
11- "E0183" , "E0227" , "E0279" , "E0280" , "E0311" , "E0313" , "E0314" , "E0315" , "E0377" , "E0461" ,
12- "E0462" , "E0464" , "E0465" , "E0472" , "E0473" , "E0474" , "E0475" , "E0476" , "E0479" , "E0480" ,
13- "E0481" , "E0482" , "E0483" , "E0484" , "E0485" , "E0486" , "E0487" , "E0488" , "E0489" , "E0514" ,
14- "E0519" , "E0523" , "E0553" , "E0554" , "E0570" , "E0629" , "E0630" , "E0640" , "E0717" , "E0727" ,
15- "E0729" ,
11+ "E0227" , "E0279" , "E0280" , "E0313" , "E0314" , "E0315" , "E0377" , "E0461" , "E0462" , "E0464" ,
12+ "E0465" , "E0473" , "E0474" , "E0475" , "E0476" , "E0479" , "E0480" , "E0481" , "E0482" , "E0483" ,
13+ "E0484" , "E0485" , "E0486" , "E0487" , "E0488" , "E0489" , "E0514" , "E0519" , "E0523" , "E0553" ,
14+ "E0554" , "E0570" , "E0629" , "E0630" , "E0640" , "E0717" , "E0729" ,
1615] ;
1716
1817// Some error codes don't have any tests apparently...
19- const IGNORE_EXPLANATION_CHECK : & [ & str ] = & [ "E0570" , "E0601" , "E0602" , "E0639" , " E0729"] ;
18+ const IGNORE_EXPLANATION_CHECK : & [ & str ] = & [ "E0570" , "E0601" , "E0602" , "E0729" ] ;
2019
2120fn check_error_code_explanation (
2221 f : & str ,
@@ -114,13 +113,18 @@ fn extract_error_codes(
114113 . expect ( "failed to canonicalize error explanation file path" ) ;
115114 match read_to_string ( & path) {
116115 Ok ( content) => {
117- if !IGNORE_EXPLANATION_CHECK . contains ( & err_code. as_str ( ) )
118- && !check_if_error_code_is_test_in_explanation ( & content, & err_code)
119- {
116+ let has_test = check_if_error_code_is_test_in_explanation ( & content, & err_code) ;
117+ if !has_test && !IGNORE_EXPLANATION_CHECK . contains ( & err_code. as_str ( ) ) {
120118 errors. push ( format ! (
121119 "`{}` doesn't use its own error code in compile_fail example" ,
122120 path. display( ) ,
123121 ) ) ;
122+ } else if has_test && IGNORE_EXPLANATION_CHECK . contains ( & err_code. as_str ( ) ) {
123+ errors. push ( format ! (
124+ "`{}` has a compile_fail example with its own error code, it shouldn't \
125+ be listed in IGNORE_EXPLANATION_CHECK!",
126+ path. display( ) ,
127+ ) ) ;
124128 }
125129 if check_error_code_explanation ( & content, error_codes, err_code) {
126130 errors. push ( format ! (
@@ -198,6 +202,11 @@ pub fn check(paths: &[&Path], bad: &mut bool) {
198202 for ( err_code, nb) in & error_codes {
199203 if !* nb && !EXEMPTED_FROM_TEST . contains ( & err_code. as_str ( ) ) {
200204 errors. push ( format ! ( "Error code {} needs to have at least one UI test!" , err_code) ) ;
205+ } else if * nb && EXEMPTED_FROM_TEST . contains ( & err_code. as_str ( ) ) {
206+ errors. push ( format ! (
207+ "Error code {} has a UI test, it shouldn't be listed into EXEMPTED_FROM_TEST!" ,
208+ err_code
209+ ) ) ;
201210 }
202211 }
203212 }
0 commit comments