about summary refs log tree commit diff
diff options
context:
space:
mode:
authorbors <bors@rust-lang.org>2015-08-25 14:16:22 +0000
committerbors <bors@rust-lang.org>2015-08-25 14:16:22 +0000
commit1806174ab430583fe09df508ddf426bea9f4a3e1 (patch)
tree8ee9c47afca7f1eb6cfc201180e973a29563ef82
parent74728862339e156ecc10dd5a515f51bbaf9b4192 (diff)
parentc4847a11dabf108c49ce2c035e44c0a8c32ac18c (diff)
downloadrust-1806174ab430583fe09df508ddf426bea9f4a3e1.tar.gz
rust-1806174ab430583fe09df508ddf426bea9f4a3e1.zip
Auto merge of #27994 - steveklabnik:rollup, r=steveklabnik
- Successful merges: #27905, #27968, #27978, #27982, #27988
- Failed merges: 
-rw-r--r--src/doc/reference.md2
-rw-r--r--src/doc/trpl/error-handling.md4
-rw-r--r--src/doc/trpl/testing.md60
-rw-r--r--src/librustc/diagnostics.rs15
4 files changed, 72 insertions, 9 deletions
diff --git a/src/doc/reference.md b/src/doc/reference.md
index 284fcf6aed0..70e3145903f 100644
--- a/src/doc/reference.md
+++ b/src/doc/reference.md
@@ -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
diff --git a/src/doc/trpl/error-handling.md b/src/doc/trpl/error-handling.md
index 8dd5a3650ef..518e65f35c0 100644
--- a/src/doc/trpl/error-handling.md
+++ b/src/doc/trpl/error-handling.md
@@ -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:
diff --git a/src/doc/trpl/testing.md b/src/doc/trpl/testing.md
index cbf33febf87..78803afd5c1 100644
--- a/src/doc/trpl/testing.md
+++ b/src/doc/trpl/testing.md
@@ -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
diff --git a/src/librustc/diagnostics.rs b/src/librustc/diagnostics.rs
index baa9750d311..5f907c6cbee 100644
--- a/src/librustc/diagnostics.rs
+++ b/src/librustc/diagnostics.rs
@@ -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:
 
 ```
@@ -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`
 ```
 "##,