Skip to content

error-pattern directive section cleaning #2348

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Merged
merged 3 commits into from
Apr 19, 2025
Merged
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
13 changes: 7 additions & 6 deletions src/tests/ui.md
Original file line number Diff line number Diff line change
Expand Up @@ -303,7 +303,7 @@ It should be preferred to using `error-pattern`, which is imprecise and non-exha
### `error-pattern`

The `error-pattern` [directive](directives.md) can be used for runtime messages, which don't
have a specific span, or in exceptional cases for compile time messages.
have a specific span, or in exceptional cases, for compile time messages.

Let's think about this test:

Expand All @@ -316,7 +316,7 @@ fn main() {
}
```

We want to ensure this shows "index out of bounds" but we cannot use the `ERROR`
We want to ensure this shows "index out of bounds", but we cannot use the `ERROR`
annotation since the runtime error doesn't have any span. Then it's time to use the
`error-pattern` directive:

Expand All @@ -333,18 +333,19 @@ fn main() {
Use of `error-pattern` is not recommended in general.

For strict testing of compile time output, try to use the line annotations `//~` as much as
possible, including `//~?` annotations for diagnostics without span.
possible, including `//~?` annotations for diagnostics without spans.

If the compile time output is target dependent or too verbose, use directive
`//@ dont-require-annotations: <diagnostic-kind>` to make the line annotation checking
non-exhaustive, some of the compiler messages can stay uncovered by annotations in this mode.
non-exhaustive.
Some of the compiler messages can stay uncovered by annotations in this mode.

For checking runtime output `//@ check-run-results` may be preferable.
For checking runtime output, `//@ check-run-results` may be preferable.

Only use `error-pattern` if none of the above works.

Line annotations `//~` are still checked in tests using `error-pattern`.
In exceptional cases use `//@ compile-flags: --error-format=human` to opt out of these checks.
In exceptional cases, use `//@ compile-flags: --error-format=human` to opt out of these checks.

### Diagnostic kinds (error levels)

Expand Down