@@ -202,6 +202,9 @@ several ways to match the message with the line (see the examples below):
202
202
* ` ~| ` : Associates the error level and message with the * same* line as the
203
203
* previous comment* . This is more convenient than using multiple carets when
204
204
there are multiple messages associated with the same line.
205
+ * ` ~? ` : Used to match error levels and messages with errors not having line
206
+ information. These can be placed on any line in the test file, but are
207
+ conventionally placed at the end.
205
208
206
209
Example:
207
210
@@ -270,10 +273,23 @@ fn main() {
270
273
//~| ERROR this pattern has 1 field, but the corresponding tuple struct has 3 fields [E0023]
271
274
```
272
275
276
+ #### Error without line information
277
+
278
+ Use ` //~? ` to match an error without line information.
279
+ ` //~? ` is precise and will not match errors if their line information is available.
280
+ It should be preferred to using ` error-pattern ` , which is imprecise and non-exhaustive.
281
+
282
+ ``` rust,ignore
283
+ //@ compile-flags: --print yyyy
284
+
285
+ //~? ERROR unknown print request: `yyyy`
286
+ ```
287
+
273
288
### ` error-pattern `
274
289
275
- The ` error-pattern ` [ directive] ( directives.md ) can be used for messages that don't
276
- have a specific span.
290
+ The ` error-pattern ` [ directive] ( directives.md ) can be used for runtime messages, which don't
291
+ have a specific span, or for compile time messages if imprecise matching is required due to
292
+ multi-line platform specific diagnostics.
277
293
278
294
Let's think about this test:
279
295
@@ -300,7 +316,9 @@ fn main() {
300
316
}
301
317
```
302
318
303
- But for strict testing, try to use the ` ERROR ` annotation as much as possible.
319
+ But for strict testing, try to use the ` ERROR ` annotation as much as possible,
320
+ including ` //~? ` annotations for diagnostics without span.
321
+ For compile time diagnostics ` error-pattern ` should very rarely be necessary.
304
322
305
323
### Error levels
306
324
@@ -353,7 +371,7 @@ would be a `.mir.stderr` and `.thir.stderr` file with the different outputs of
353
371
the different revisions.
354
372
355
373
> Note: cfg revisions also work inside the source code with ` #[cfg] ` attributes.
356
- >
374
+ >
357
375
> By convention, the ` FALSE ` cfg is used to have an always-false config.
358
376
359
377
## Controlling pass/fail expectations
0 commit comments