diff options
| author | Vadim Petrochenkov <vadim.petrochenkov@gmail.com> | 2025-03-29 02:41:32 +0300 |
|---|---|---|
| committer | Vadim Petrochenkov <vadim.petrochenkov@gmail.com> | 2025-04-03 11:08:55 +0300 |
| commit | 4d649906900cd833b0680f53b8c197b087711a4a (patch) | |
| tree | a840262c32e0e954ebe3f6dfc4ae1c3eda51eaba /src | |
| parent | b6d74b5e15b0d479a98b8b18bb70050511108882 (diff) | |
| download | rust-4d649906900cd833b0680f53b8c197b087711a4a.tar.gz rust-4d649906900cd833b0680f53b8c197b087711a4a.zip | |
compiletest: Require `//~` annotations even if `error-pattern` is specified
Diffstat (limited to 'src')
| -rw-r--r-- | src/doc/rustc-dev-guide/src/tests/ui.md | 3 | ||||
| -rw-r--r-- | src/tools/compiletest/src/runtest/ui.rs | 16 |
2 files changed, 9 insertions, 10 deletions
diff --git a/src/doc/rustc-dev-guide/src/tests/ui.md b/src/doc/rustc-dev-guide/src/tests/ui.md index 1190c2646af..6f412a7a60e 100644 --- a/src/doc/rustc-dev-guide/src/tests/ui.md +++ b/src/doc/rustc-dev-guide/src/tests/ui.md @@ -335,6 +335,9 @@ But for strict testing, try to use the `ERROR` annotation as much as possible, including `//~?` annotations for diagnostics without span. For compile time diagnostics `error-pattern` should very rarely be necessary. +Per-line annotations (`//~`) are still checked in tests using `error-pattern`, +to opt out of these checks in exceptional cases use `//@ compile-flags: --error-format=human`. + ### Error levels The error levels that you can have are: diff --git a/src/tools/compiletest/src/runtest/ui.rs b/src/tools/compiletest/src/runtest/ui.rs index 9b5b8b56b60..974e5170465 100644 --- a/src/tools/compiletest/src/runtest/ui.rs +++ b/src/tools/compiletest/src/runtest/ui.rs @@ -169,16 +169,9 @@ impl TestCx<'_> { self.props.error_patterns ); - let check_patterns = should_run == WillExecute::No - && (!self.props.error_patterns.is_empty() - || !self.props.regex_error_patterns.is_empty()); if !explicit && self.config.compare_mode.is_none() { - let check_annotations = !check_patterns || !expected_errors.is_empty(); - - if check_annotations { - // "//~ERROR comments" - self.check_expected_errors(expected_errors, &proc_res); - } + // "//~ERROR comments" + self.check_expected_errors(expected_errors, &proc_res); } else if explicit && !expected_errors.is_empty() { let msg = format!( "line {}: cannot combine `--error-format` with {} annotations; use `error-pattern` instead", @@ -188,7 +181,10 @@ impl TestCx<'_> { self.fatal(&msg); } let output_to_check = self.get_output(&proc_res); - if check_patterns { + if should_run == WillExecute::No + && (!self.props.error_patterns.is_empty() + || !self.props.regex_error_patterns.is_empty()) + { // "// error-pattern" comments self.check_all_error_patterns(&output_to_check, &proc_res, pm); } |
