1515//!
1616//! 4. We check that the error code is actually emitted by the compiler.
1717//! - This is done by searching `compiler/` with a regex.
18- //!
19- //! This tidy check was merged and refactored from two others. See #PR_NUM for information about linting changes that occurred during this refactor.
2018
2119use std:: { ffi:: OsStr , fs, path:: Path } ;
2220
@@ -57,7 +55,7 @@ pub fn check(root_path: &Path, search_paths: &[&Path], verbose: bool, bad: &mut
5755 let no_longer_emitted = check_error_codes_docs ( root_path, & error_codes, & mut errors, verbose) ;
5856
5957 // Stage 3: check list has UI tests
60- check_error_codes_tests ( root_path, & error_codes, & mut errors, verbose) ;
58+ check_error_codes_tests ( root_path, & error_codes, & mut errors, verbose, & no_longer_emitted ) ;
6159
6260 // Stage 4: check list is emitted by compiler
6361 check_error_codes_used ( search_paths, & error_codes, & mut errors, & no_longer_emitted, verbose) ;
@@ -174,22 +172,21 @@ fn check_error_codes_docs(
174172 return ;
175173 }
176174
177- let ( found_code_example, found_proper_doctest, emit_ignore_warning, emit_no_longer_warning ) =
175+ let ( found_code_example, found_proper_doctest, emit_ignore_warning, no_longer_emitted ) =
178176 check_explanation_has_doctest ( & contents, & err_code) ;
177+
179178 if emit_ignore_warning {
180179 verbose_print ! (
181180 verbose,
182181 "warning: Error code `{err_code}` uses the ignore header. This should not be used, add the error code to the \
183182 `IGNORE_DOCTEST_CHECK` constant instead."
184183 ) ;
185184 }
186- if emit_no_longer_warning {
185+
186+ if no_longer_emitted {
187187 no_longer_emitted_codes. push ( err_code. to_owned ( ) ) ;
188- verbose_print ! (
189- verbose,
190- "warning: Error code `{err_code}` is no longer emitted and should be removed entirely."
191- ) ;
192188 }
189+
193190 if !found_code_example {
194191 verbose_print ! (
195192 verbose,
@@ -226,7 +223,7 @@ fn check_explanation_has_doctest(explanation: &str, err_code: &str) -> (bool, bo
226223 let mut found_proper_doctest = false ;
227224
228225 let mut emit_ignore_warning = false ;
229- let mut emit_no_longer_warning = false ;
226+ let mut no_longer_emitted = false ;
230227
231228 for line in explanation. lines ( ) {
232229 let line = line. trim ( ) ;
@@ -246,13 +243,13 @@ fn check_explanation_has_doctest(explanation: &str, err_code: &str) -> (bool, bo
246243 } else if line
247244 . starts_with ( "#### Note: this error code is no longer emitted by the compiler" )
248245 {
249- emit_no_longer_warning = true ;
246+ no_longer_emitted = true ;
250247 found_code_example = true ;
251248 found_proper_doctest = true ;
252249 }
253250 }
254251
255- ( found_code_example, found_proper_doctest, emit_ignore_warning, emit_no_longer_warning )
252+ ( found_code_example, found_proper_doctest, emit_ignore_warning, no_longer_emitted )
256253}
257254
258255// Stage 3: Checks that each error code has a UI test in the correct directory
@@ -261,6 +258,7 @@ fn check_error_codes_tests(
261258 error_codes : & [ String ] ,
262259 errors : & mut Vec < String > ,
263260 verbose : bool ,
261+ no_longer_emitted : & [ String ] ,
264262) {
265263 let tests_path = root_path. join ( Path :: new ( ERROR_TESTS_PATH ) ) ;
266264
@@ -295,6 +293,11 @@ fn check_error_codes_tests(
295293 }
296294 } ;
297295
296+ if no_longer_emitted. contains ( code) {
297+ // UI tests *can't* contain error codes that are no longer emitted.
298+ continue ;
299+ }
300+
298301 let mut found_code = false ;
299302
300303 for line in file. lines ( ) {
0 commit comments