Skip to content

Commit

Permalink
Auto merge of #27994 - steveklabnik:rollup, r=steveklabnik
Browse files Browse the repository at this point in the history
- Successful merges: #27905, #27968, #27978, #27982, #27988
- Failed merges:
  • Loading branch information
bors committed Aug 25, 2015
2 parents 7472886 + c4847a1 commit 1806174
Show file tree
Hide file tree
Showing 4 changed files with 72 additions and 9 deletions.
2 changes: 1 addition & 1 deletion src/doc/reference.md
Original file line number Diff line number Diff line change
Expand Up @@ -1452,7 +1452,7 @@ fn draw_twice<T: Shape>(surface: Surface, sh: T) {
}
```

Traits also define an [trait object](#trait-objects) with the same
Traits also define a [trait object](#trait-objects) with the same
name as the trait. Values of this type are created by coercing from a
pointer of some specific type to a pointer of trait type. For example,
`&T` could be coerced to `&Shape` if `T: Shape` holds (and similarly
Expand Down
4 changes: 2 additions & 2 deletions src/doc/trpl/error-handling.md
Original file line number Diff line number Diff line change
Expand Up @@ -208,8 +208,8 @@ Because these kinds of situations are relatively rare, use panics sparingly.

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

If we don't want to handle this error, and would rather just abort the program,
we can use the `unwrap()` method:
Expand Down
60 changes: 60 additions & 0 deletions src/doc/trpl/testing.md
Original file line number Diff line number Diff line change
Expand Up @@ -219,6 +219,66 @@ fn it_works() {
This is a very common use of `assert_eq!`: call some function with
some known arguments and compare it to the expected output.

# The `ignore` attribute

Sometimes a few specific tests can be very time-consuming to execute. These
can be disabled by default by using the `ignore` attribute:

```rust
#[test]
fn it_works() {
assert_eq!(4, add_two(2));
}

#[test]
#[ignore]
fn expensive_test() {
// code that takes an hour to run
}
```

Now we run our tests and see that `it_works` is run, but `expensive_test` is
not:

```bash
$ cargo test
Compiling adder v0.0.1 (file:///home/you/projects/adder)
Running target/adder-91b3e234d4ed382a

running 2 tests
test expensive_test ... ignored
test it_works ... ok

test result: ok. 1 passed; 0 failed; 1 ignored; 0 measured

Doc-tests adder

running 0 tests

test result: ok. 0 passed; 0 failed; 0 ignored; 0 measured
```

The expensive tests can be run explicitly using `cargo test -- --ignored`:

```bash
$ cargo test -- --ignored
Running target/adder-91b3e234d4ed382a

running 1 test
test expensive_test ... ok

test result: ok. 1 passed; 0 failed; 0 ignored; 0 measured

Doc-tests adder

running 0 tests

test result: ok. 0 passed; 0 failed; 0 ignored; 0 measured
```

The `--ignored` argument is an argument to the test binary, and not to cargo,
which is why the command is `cargo test -- --ignored`.

# The `tests` module

There is one way in which our existing example is not idiomatic: it's
Expand Down
15 changes: 9 additions & 6 deletions src/librustc/diagnostics.rs
Original file line number Diff line number Diff line change
Expand Up @@ -731,9 +731,14 @@ type X = u32; // ok!
"##,

E0133: r##"
Using unsafe functionality, such as dereferencing raw pointers and calling
functions via FFI or marked as unsafe, is potentially dangerous and disallowed
by safety checks. These safety checks can be relaxed for a section of the code
Using unsafe functionality, is potentially dangerous and disallowed
by safety checks. Examples:
- Dereferencing raw pointers
- Calling functions via FFI
- Calling functions marked unsafe
These safety checks can be relaxed for a section of the code
by wrapping the unsafe instructions with an `unsafe` block. For instance:
```
Expand Down Expand Up @@ -831,9 +836,7 @@ is a size mismatch in one of the impls.
It is also possible to manually transmute:
```
let result: SomeType = mem::uninitialized();
unsafe { copy_nonoverlapping(&v, &result) };
result // `v` transmuted to type `SomeType`
ptr::read(&v as *const _ as *const SomeType) // `v` transmuted to `SomeType`
```
"##,

Expand Down

0 comments on commit 1806174

Please sign in to comment.