Skip to content

Commit 806114f

Browse files
authored
Rollup merge of #139100 - petrochenkov:errbelow, r=jieyouxu
compiletest: Support matching diagnostics on lines below Using `//~vvv ERROR`. This is not needed often, but it's easy to support, and it allows to eliminate a class of `error-pattern`s that cannot be eliminated in any other way. See the diff for the examples of such patterns coming from parser. Some of them can be matched by `//~ ERROR` or `//~^ ERROR` as well (when the final newline is allowed), but it changes the shape of reported spans, so I chose to keep the spans by using `//~v ERROR`.
2 parents 2fe1dcd + 628eb70 commit 806114f

File tree

1 file changed

+15
-0
lines changed

1 file changed

+15
-0
lines changed

Diff for: src/tests/ui.md

+15
Original file line numberDiff line numberDiff line change
@@ -202,6 +202,9 @@ several ways to match the message with the line (see the examples below):
202202
* `~|`: Associates the error level and message with the *same* line as the
203203
*previous comment*. This is more convenient than using multiple carets when
204204
there are multiple messages associated with the same line.
205+
* `~v`: Associates the error level and message with the *next* error
206+
annotation line. Each symbol (`v`) that you add adds a line to this, so `~vvv`
207+
is three lines below the error annotation line.
205208
* `~?`: Used to match error levels and messages with errors not having line
206209
information. These can be placed on any line in the test file, but are
207210
conventionally placed at the end.
@@ -273,6 +276,18 @@ fn main() {
273276
//~| ERROR this pattern has 1 field, but the corresponding tuple struct has 3 fields [E0023]
274277
```
275278

279+
#### Positioned above error line
280+
281+
Use the `//~v` idiom with number of v's in the string to indicate the number
282+
of lines below. This is typically used in lexer or parser tests matching on errors like unclosed
283+
delimiter or unclosed literal happening at the end of file.
284+
285+
```rust,ignore
286+
// ignore-tidy-trailing-newlines
287+
//~v ERROR this file contains an unclosed delimiter
288+
fn main((ؼ
289+
```
290+
276291
#### Error without line information
277292

278293
Use `//~?` to match an error without line information.

0 commit comments

Comments
 (0)