15
15
//!
16
16
//! 4. We check that the error code is actually emitted by the compiler.
17
17
//! - 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.
20
18
21
19
use std:: { ffi:: OsStr , fs, path:: Path } ;
22
20
@@ -57,7 +55,7 @@ pub fn check(root_path: &Path, search_paths: &[&Path], verbose: bool, bad: &mut
57
55
let no_longer_emitted = check_error_codes_docs ( root_path, & error_codes, & mut errors, verbose) ;
58
56
59
57
// 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 ) ;
61
59
62
60
// Stage 4: check list is emitted by compiler
63
61
check_error_codes_used ( search_paths, & error_codes, & mut errors, & no_longer_emitted, verbose) ;
@@ -174,22 +172,21 @@ fn check_error_codes_docs(
174
172
return ;
175
173
}
176
174
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 ) =
178
176
check_explanation_has_doctest ( & contents, & err_code) ;
177
+
179
178
if emit_ignore_warning {
180
179
verbose_print ! (
181
180
verbose,
182
181
"warning: Error code `{err_code}` uses the ignore header. This should not be used, add the error code to the \
183
182
`IGNORE_DOCTEST_CHECK` constant instead."
184
183
) ;
185
184
}
186
- if emit_no_longer_warning {
185
+
186
+ if no_longer_emitted {
187
187
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
- ) ;
192
188
}
189
+
193
190
if !found_code_example {
194
191
verbose_print ! (
195
192
verbose,
@@ -226,7 +223,7 @@ fn check_explanation_has_doctest(explanation: &str, err_code: &str) -> (bool, bo
226
223
let mut found_proper_doctest = false ;
227
224
228
225
let mut emit_ignore_warning = false ;
229
- let mut emit_no_longer_warning = false ;
226
+ let mut no_longer_emitted = false ;
230
227
231
228
for line in explanation. lines ( ) {
232
229
let line = line. trim ( ) ;
@@ -246,13 +243,13 @@ fn check_explanation_has_doctest(explanation: &str, err_code: &str) -> (bool, bo
246
243
} else if line
247
244
. starts_with ( "#### Note: this error code is no longer emitted by the compiler" )
248
245
{
249
- emit_no_longer_warning = true ;
246
+ no_longer_emitted = true ;
250
247
found_code_example = true ;
251
248
found_proper_doctest = true ;
252
249
}
253
250
}
254
251
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 )
256
253
}
257
254
258
255
// Stage 3: Checks that each error code has a UI test in the correct directory
@@ -261,6 +258,7 @@ fn check_error_codes_tests(
261
258
error_codes : & [ String ] ,
262
259
errors : & mut Vec < String > ,
263
260
verbose : bool ,
261
+ no_longer_emitted : & [ String ] ,
264
262
) {
265
263
let tests_path = root_path. join ( Path :: new ( ERROR_TESTS_PATH ) ) ;
266
264
@@ -295,6 +293,11 @@ fn check_error_codes_tests(
295
293
}
296
294
} ;
297
295
296
+ if no_longer_emitted. contains ( code) {
297
+ // UI tests *can't* contain error codes that are no longer emitted.
298
+ continue ;
299
+ }
300
+
298
301
let mut found_code = false ;
299
302
300
303
for line in file. lines ( ) {
0 commit comments