diff --git a/src/doc/nomicon/coercions.md b/src/doc/nomicon/coercions.md index 2e33a6729d1c..1d2897ce3bd1 100644 --- a/src/doc/nomicon/coercions.md +++ b/src/doc/nomicon/coercions.md @@ -22,7 +22,7 @@ Coercion is allowed between the following types: for all pointer types (including smart pointers like Box and Rc). Unsize is only implemented automatically, and enables the following transformations: -* `[T, ..n]` => `[T]` +* `[T; n]` => `[T]` * `T` => `Trait` where `T: Trait` * `Foo<..., T, ...>` => `Foo<..., U, ...>` where: * `T: Unsize` diff --git a/src/doc/nomicon/safe-unsafe-meaning.md b/src/doc/nomicon/safe-unsafe-meaning.md index 2f15b7050e36..e9037b56ff9d 100644 --- a/src/doc/nomicon/safe-unsafe-meaning.md +++ b/src/doc/nomicon/safe-unsafe-meaning.md @@ -125,7 +125,7 @@ unsafe impl UnsafeOrd for MyType { But it's probably not the implementation you want. Rust has traditionally avoided making traits unsafe because it makes Unsafe -pervasive, which is not desirable. Send and Sync are unsafe is because thread +pervasive, which is not desirable. The reason Send and Sync are unsafe is because thread safety is a *fundamental property* that unsafe code cannot possibly hope to defend against in the same way it would defend against a bad Ord implementation. The only way to possibly defend against thread-unsafety would be to *not use diff --git a/src/doc/reference.md b/src/doc/reference.md index b4dec8f1fef9..284fcf6aed0c 100644 --- a/src/doc/reference.md +++ b/src/doc/reference.md @@ -2073,6 +2073,7 @@ The following configurations must be defined by the implementation: * `target_pointer_width = "..."`. Target pointer width in bits. This is set to `"32"` for targets with 32-bit pointers, and likewise set to `"64"` for 64-bit pointers. +* `test`. Enabled when compiling the test harness (using the `--test` flag). * `unix`. See `target_family`. * `windows`. See `target_family`. diff --git a/src/doc/trpl/concurrency.md b/src/doc/trpl/concurrency.md index 17627da3513e..e00fe75013e2 100644 --- a/src/doc/trpl/concurrency.md +++ b/src/doc/trpl/concurrency.md @@ -343,12 +343,14 @@ threads as a simple isolation mechanism: ```rust use std::thread; -let result = thread::spawn(move || { +let handle = thread::spawn(move || { panic!("oops!"); -}).join(); +}); + +let result = handle.join(); assert!(result.is_err()); ``` -Our `Thread` gives us a `Result` back, which allows us to check if the thread +`Thread.join()` gives us a `Result` back, which allows us to check if the thread has panicked or not. diff --git a/src/doc/trpl/documentation.md b/src/doc/trpl/documentation.md index 556af6625c0f..0a471beb4391 100644 --- a/src/doc/trpl/documentation.md +++ b/src/doc/trpl/documentation.md @@ -73,8 +73,8 @@ hello.rs:4 } ``` This [unfortunate error](https://github.com/rust-lang/rust/issues/22547) is -correct: documentation comments apply to the thing after them, and there's no -thing after that last comment. +correct: documentation comments apply to the thing after them, and there's +nothing after that last comment. [rc-new]: https://doc.rust-lang.org/nightly/std/rc/struct.Rc.html#method.new @@ -196,10 +196,10 @@ This will highlight according to whatever language you're showing off. If you're just showing plain text, choose `text`. It's important to choose the correct annotation here, because `rustdoc` uses it -in an interesting way: It can be used to actually test your examples, so that -they don't get out of date. If you have some C code but `rustdoc` thinks it's -Rust because you left off the annotation, `rustdoc` will complain when trying to -generate the documentation. +in an interesting way: It can be used to actually test your examples in a +library crate, so that they don't get out of date. If you have some C code but +`rustdoc` thinks it's Rust because you left off the annotation, `rustdoc` will +complain when trying to generate the documentation. ## Documentation as tests @@ -377,8 +377,8 @@ $ rustdoc --test path/to/my/crate/root.rs $ cargo test ``` -That's right, `cargo test` tests embedded documentation too. However, -`cargo test` will not test binary crates, only library ones. This is +That's right, `cargo test` tests embedded documentation too. **However, +`cargo test` will not test binary crates, only library ones.** This is due to the way `rustdoc` works: it links against the library to be tested, but with a binary, there’s nothing to link to. diff --git a/src/doc/trpl/testing.md b/src/doc/trpl/testing.md index a5a0127031ae..cbf33febf876 100644 --- a/src/doc/trpl/testing.md +++ b/src/doc/trpl/testing.md @@ -355,8 +355,8 @@ Let's finally check out that third section: documentation tests. Nothing is better than documentation with examples. Nothing is worse than examples that don't actually work, because the code has changed since the documentation has been written. To this end, Rust supports automatically -running examples in your documentation. Here's a fleshed-out `src/lib.rs` -with examples: +running examples in your documentation (**note:** this only works in library +crates, not binary crates). Here's a fleshed-out `src/lib.rs` with examples: ```rust,ignore //! The `adder` crate provides functions that add numbers to other numbers. diff --git a/src/libcore/intrinsics.rs b/src/libcore/intrinsics.rs index 5cbca1ba4c68..ece285a83135 100644 --- a/src/libcore/intrinsics.rs +++ b/src/libcore/intrinsics.rs @@ -247,11 +247,11 @@ extern "rust-intrinsic" { /// ``` /// use std::mem; /// - /// let v: &[u8] = unsafe { mem::transmute("L") }; - /// assert!(v == [76]); + /// let array: &[u8] = unsafe { mem::transmute("Rust") }; + /// assert_eq!(array, [82, 117, 115, 116]); /// ``` #[stable(feature = "rust1", since = "1.0.0")] - pub fn transmute(e: T) -> U; + pub fn transmute(e: T) -> U; /// Gives the address for the return value of the enclosing function. ///