Auto merge of #27947 - steveklabnik:rollup, r=steveklabnik
- Successful merges: #27903, #27904, #27920, #27921, #27924, #27926, #27934, #27935 - Failed merges:
This commit is contained in:
commit
10d69db0a8
7 changed files with 21 additions and 18 deletions
|
|
@ -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<U>`
|
||||
|
|
|
|||
|
|
@ -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
|
||||
|
|
|
|||
|
|
@ -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`.
|
||||
|
||||
|
|
|
|||
|
|
@ -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.
|
||||
|
|
|
|||
|
|
@ -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.
|
||||
|
||||
|
|
|
|||
|
|
@ -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.
|
||||
|
|
|
|||
|
|
@ -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<T,U>(e: T) -> U;
|
||||
pub fn transmute<T, U>(e: T) -> U;
|
||||
|
||||
/// Gives the address for the return value of the enclosing function.
|
||||
///
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue