Skip to content

Commit da96d22

Browse files
jooertManishearth
authored andcommitted
Rename should_fail to should_panic in docs
1 parent 12cb7c6 commit da96d22

File tree

3 files changed

+9
-9
lines changed

3 files changed

+9
-9
lines changed

src/doc/reference.md

+1-1
Original file line numberDiff line numberDiff line change
@@ -2068,7 +2068,7 @@ type int8_t = i8;
20682068
item](#language-items) for more details.
20692069
- `test` - indicates that this function is a test function, to only be compiled
20702070
in case of `--test`.
2071-
- `should_fail` - indicates that this test function should panic, inverting the success condition.
2071+
- `should_panic` - indicates that this test function should panic, inverting the success condition.
20722072
- `cold` - The function is unlikely to be executed, so optimize it (and calls
20732073
to it) differently.
20742074

src/doc/trpl/functions.md

+1-1
Original file line numberDiff line numberDiff line change
@@ -179,7 +179,7 @@ Because this function will cause a crash, it will never return, and so it has
179179
the type '`!`', which is read "diverges." A diverging function can be used
180180
as any type:
181181

182-
```should_fail
182+
```should_panic
183183
# fn diverges() -> ! {
184184
# panic!("This function never returns!");
185185
# }

src/doc/trpl/testing.md

+7-7
Original file line numberDiff line numberDiff line change
@@ -129,11 +129,11 @@ $ echo $?
129129

130130
This is useful if you want to integrate `cargo test` into other tooling.
131131

132-
We can invert our test's failure with another attribute: `should_fail`:
132+
We can invert our test's failure with another attribute: `should_panic`:
133133

134134
```rust
135135
#[test]
136-
#[should_fail]
136+
#[should_panic]
137137
fn it_works() {
138138
assert!(false);
139139
}
@@ -163,13 +163,13 @@ equality:
163163

164164
```rust
165165
#[test]
166-
#[should_fail]
166+
#[should_panic]
167167
fn it_works() {
168168
assert_eq!("Hello", "world");
169169
}
170170
```
171171

172-
Does this test pass or fail? Because of the `should_fail` attribute, it
172+
Does this test pass or fail? Because of the `should_panic` attribute, it
173173
passes:
174174

175175
```bash
@@ -189,15 +189,15 @@ running 0 tests
189189
test result: ok. 0 passed; 0 failed; 0 ignored; 0 measured
190190
```
191191

192-
`should_fail` tests can be fragile, as it's hard to guarantee that the test
192+
`should_panic` tests can be fragile, as it's hard to guarantee that the test
193193
didn't fail for an unexpected reason. To help with this, an optional `expected`
194-
parameter can be added to the `should_fail` attribute. The test harness will
194+
parameter can be added to the `should_panic` attribute. The test harness will
195195
make sure that the failure message contains the provided text. A safer version
196196
of the example above would be:
197197

198198
```
199199
#[test]
200-
#[should_fail(expected = "assertion failed")]
200+
#[should_panic(expected = "assertion failed")]
201201
fn it_works() {
202202
assert_eq!("Hello", "world");
203203
}

0 commit comments

Comments
 (0)