Skip to content

Commit 1806174

Browse files
committed
Auto merge of #27994 - steveklabnik:rollup, r=steveklabnik
- Successful merges: #27905, #27968, #27978, #27982, #27988 - Failed merges:
2 parents 7472886 + c4847a1 commit 1806174

File tree

4 files changed

+72
-9
lines changed

4 files changed

+72
-9
lines changed

src/doc/reference.md

+1-1
Original file line numberDiff line numberDiff line change
@@ -1452,7 +1452,7 @@ fn draw_twice<T: Shape>(surface: Surface, sh: T) {
14521452
}
14531453
```
14541454

1455-
Traits also define an [trait object](#trait-objects) with the same
1455+
Traits also define a [trait object](#trait-objects) with the same
14561456
name as the trait. Values of this type are created by coercing from a
14571457
pointer of some specific type to a pointer of trait type. For example,
14581458
`&T` could be coerced to `&Shape` if `T: Shape` holds (and similarly

src/doc/trpl/error-handling.md

+2-2
Original file line numberDiff line numberDiff line change
@@ -208,8 +208,8 @@ Because these kinds of situations are relatively rare, use panics sparingly.
208208

209209
In certain circumstances, even though a function may fail, we may want to treat
210210
it as a panic instead. For example, `io::stdin().read_line(&mut buffer)` returns
211-
a `Result<usize>`, when there is an error reading the line. This allows us to
212-
handle and possibly recover from error.
211+
a `Result<usize>`, which can indicate an error if one occurs when reading the line.
212+
This allows us to handle and possibly recover from errors.
213213

214214
If we don't want to handle this error, and would rather just abort the program,
215215
we can use the `unwrap()` method:

src/doc/trpl/testing.md

+60
Original file line numberDiff line numberDiff line change
@@ -219,6 +219,66 @@ fn it_works() {
219219
This is a very common use of `assert_eq!`: call some function with
220220
some known arguments and compare it to the expected output.
221221

222+
# The `ignore` attribute
223+
224+
Sometimes a few specific tests can be very time-consuming to execute. These
225+
can be disabled by default by using the `ignore` attribute:
226+
227+
```rust
228+
#[test]
229+
fn it_works() {
230+
assert_eq!(4, add_two(2));
231+
}
232+
233+
#[test]
234+
#[ignore]
235+
fn expensive_test() {
236+
// code that takes an hour to run
237+
}
238+
```
239+
240+
Now we run our tests and see that `it_works` is run, but `expensive_test` is
241+
not:
242+
243+
```bash
244+
$ cargo test
245+
Compiling adder v0.0.1 (file:///home/you/projects/adder)
246+
Running target/adder-91b3e234d4ed382a
247+
248+
running 2 tests
249+
test expensive_test ... ignored
250+
test it_works ... ok
251+
252+
test result: ok. 1 passed; 0 failed; 1 ignored; 0 measured
253+
254+
Doc-tests adder
255+
256+
running 0 tests
257+
258+
test result: ok. 0 passed; 0 failed; 0 ignored; 0 measured
259+
```
260+
261+
The expensive tests can be run explicitly using `cargo test -- --ignored`:
262+
263+
```bash
264+
$ cargo test -- --ignored
265+
Running target/adder-91b3e234d4ed382a
266+
267+
running 1 test
268+
test expensive_test ... ok
269+
270+
test result: ok. 1 passed; 0 failed; 0 ignored; 0 measured
271+
272+
Doc-tests adder
273+
274+
running 0 tests
275+
276+
test result: ok. 0 passed; 0 failed; 0 ignored; 0 measured
277+
```
278+
279+
The `--ignored` argument is an argument to the test binary, and not to cargo,
280+
which is why the command is `cargo test -- --ignored`.
281+
222282
# The `tests` module
223283

224284
There is one way in which our existing example is not idiomatic: it's

src/librustc/diagnostics.rs

+9-6
Original file line numberDiff line numberDiff line change
@@ -731,9 +731,14 @@ type X = u32; // ok!
731731
"##,
732732

733733
E0133: r##"
734-
Using unsafe functionality, such as dereferencing raw pointers and calling
735-
functions via FFI or marked as unsafe, is potentially dangerous and disallowed
736-
by safety checks. These safety checks can be relaxed for a section of the code
734+
Using unsafe functionality, is potentially dangerous and disallowed
735+
by safety checks. Examples:
736+
737+
- Dereferencing raw pointers
738+
- Calling functions via FFI
739+
- Calling functions marked unsafe
740+
741+
These safety checks can be relaxed for a section of the code
737742
by wrapping the unsafe instructions with an `unsafe` block. For instance:
738743
739744
```
@@ -831,9 +836,7 @@ is a size mismatch in one of the impls.
831836
It is also possible to manually transmute:
832837
833838
```
834-
let result: SomeType = mem::uninitialized();
835-
unsafe { copy_nonoverlapping(&v, &result) };
836-
result // `v` transmuted to type `SomeType`
839+
ptr::read(&v as *const _ as *const SomeType) // `v` transmuted to `SomeType`
837840
```
838841
"##,
839842

0 commit comments

Comments
 (0)