Skip to content

Commit 8cb85a5

Browse files
ehusstraviscross
authored andcommitted
Update ignore to use attribute template
This updates the ignore attribute to use the attribute template. This generally just makes things more explicit, and restructured to follow the template.
1 parent 9571d4d commit 8cb85a5

File tree

1 file changed

+38
-13
lines changed

1 file changed

+38
-13
lines changed

src/attributes/testing.md

Lines changed: 38 additions & 13 deletions
Original file line numberDiff line numberDiff line change
@@ -52,24 +52,49 @@ r[attributes.testing.ignore]
5252
## The `ignore` attribute
5353

5454
r[attributes.testing.ignore.intro]
55-
A function annotated with the `test` attribute can also be annotated with the
56-
`ignore` attribute. The *`ignore` attribute* tells the test harness to not
57-
execute that function as a test. It will still be compiled when in test mode.
55+
The *`ignore` [attribute][attributes]* can be used with the [`test` attribute][attributes.testing.test] to tell the test harness to not execute that function as a test.
56+
57+
> [!EXAMPLE]
58+
> ```rust
59+
> #[test]
60+
> #[ignore]
61+
> fn check_thing() {
62+
> //
63+
> }
64+
> ```
65+
66+
> [!NOTE]
67+
> The `rustc` test harness supports the `--include-ignored` flag to force ignored tests to be run.
5868
5969
r[attributes.testing.ignore.syntax]
60-
The `ignore` attribute may optionally be written with the [MetaNameValueStr]
61-
syntax to specify a reason why the test is ignored.
70+
The `ignore` attribute uses either the [MetaWord] or [MetaNameValueStr] syntax.
6271
63-
```rust
64-
#[test]
65-
#[ignore = "not yet implemented"]
66-
fn mytest() {
67-
//
68-
}
69-
```
72+
r[attributes.testing.ignore.reason]
73+
The [MetaNameValueStr] form of the `ignore` attribute provides a way to specify a reason why the test is ignored.
74+
75+
> [!EXAMPLE]
76+
> ```rust
77+
> #[test]
78+
> #[ignore = "not yet implemented"]
79+
> fn mytest() {
80+
> //
81+
> }
82+
> ```
83+
84+
r[attributes.testing.ignore.allowed-positions]
85+
The `ignore` attribute may be applied to functions annotated with the `test` attribute.
7086
7187
> [!NOTE]
72-
> The `rustc` test harness supports the `--include-ignored` flag to force ignored tests to be run.
88+
> `rustc` currently warns when `ignore` is used in some other situations. This may become an error in the future.
89+
90+
r[attributes.testing.ignore.duplicates]
91+
Only the first instance of `ignore` on a function is honored.
92+
93+
> [!NOTE]
94+
> `rustc` currently ignores duplicate `ignore` attributes. This may become an error in the future.
95+
96+
r[attributes.testing.ignore.behavior]
97+
Ignored tests are still compiled when in test mode, but they are not executed.
7398
7499
r[attributes.testing.should_panic]
75100
## The `should_panic` attribute

0 commit comments

Comments
 (0)