@@ -207,6 +207,9 @@ source.
207
207
* ` needs-sanitizer-{address,leak,memory,thread} ` - indicates that test
208
208
requires a target with a support for AddressSanitizer, LeakSanitizer,
209
209
MemorySanitizer or ThreadSanitizer respectively.
210
+ * ` error-pattern ` checks the diagnostics just like the ` ERROR ` annotation
211
+ without specifying error line. This is useful when the error doesn't give
212
+ any span.
210
213
211
214
[ `header.rs` ] : https://github.com/rust-lang/rust/tree/master/src/tools/compiletest/src/header.rs
212
215
[ bless ] : ./running.md#editing-and-updating-the-reference-files
@@ -291,6 +294,36 @@ fn main() {
291
294
//~| ERROR this pattern has 1 field, but the corresponding tuple struct has 3 fields [E0023]
292
295
```
293
296
297
+ #### When error line cannot be specified
298
+
299
+ Let's think about this test:
300
+
301
+ ``` rust,ignore
302
+ fn main() {
303
+ let a: *const [_] = &[1, 2, 3];
304
+ unsafe {
305
+ let _b = (*a)[3];
306
+ }
307
+ }
308
+ ```
309
+
310
+ We want to ensure this shows "index out of bounds" but we cannot use the ` ERROR ` annotation
311
+ since the error doesn't have any span. Then it's time to use the ` error-pattern ` :
312
+
313
+ ``` rust,ignore
314
+ // error-pattern: index out of bounds
315
+ fn main() {
316
+ let a: *const [_] = &[1, 2, 3];
317
+ unsafe {
318
+ let _b = (*a)[3];
319
+ }
320
+ }
321
+ ```
322
+
323
+ But for strict testing, try to use the ` ERROR ` annotation as much as possible.
324
+
325
+ #### Error levels
326
+
294
327
The error levels that you can have are:
295
328
296
329
1 . ` ERROR `
0 commit comments