@@ -207,6 +207,9 @@ source.
207207* ` needs-sanitizer-{address,leak,memory,thread} ` - indicates that test
208208 requires a target with a support for AddressSanitizer, LeakSanitizer,
209209 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.
210213
211214[ `header.rs` ] : https://github.com/rust-lang/rust/tree/master/src/tools/compiletest/src/header.rs
212215[ bless ] : ./running.md#editing-and-updating-the-reference-files
@@ -291,6 +294,36 @@ fn main() {
291294//~| ERROR this pattern has 1 field, but the corresponding tuple struct has 3 fields [E0023]
292295```
293296
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+
294327The error levels that you can have are:
295328
2963291 . ` ERROR `
0 commit comments