Skip to content

Commit 4621dd2

Browse files
committed
Auto merge of #32402 - steveklabnik:rollup, r=steveklabnik
Rollup of 6 pull requests - Successful merges: #32322, #32339, #32340, #32373, #32376, #32397 - Failed merges:
2 parents 21922e1 + 6a3c7d5 commit 4621dd2

File tree

6 files changed

+55
-10
lines changed

6 files changed

+55
-10
lines changed

src/doc/book/error-handling.md

+10
Original file line numberDiff line numberDiff line change
@@ -2019,6 +2019,16 @@ impl Error for CliError {
20192019
CliError::NotFound => "not found",
20202020
}
20212021
}
2022+
2023+
fn cause(&self) -> Option<&error::Error> {
2024+
match *self {
2025+
CliError::Io(ref err) => Some(err),
2026+
CliError::Parse(ref err) => Some(err),
2027+
// Our custom error doesn't have an underlying cause, but we could
2028+
// modify it so that it does.
2029+
CliError::NotFound() => None,
2030+
}
2031+
}
20222032
}
20232033
```
20242034

src/doc/book/match.md

+3-3
Original file line numberDiff line numberDiff line change
@@ -36,10 +36,10 @@ give us an error:
3636
error: non-exhaustive patterns: `_` not covered
3737
```
3838

39-
Rust is telling us that we forgot a value. The compiler infers from `x` that it
40-
can have any positive 32bit value; for example 1 to 2,147,483,647. The `_` acts
39+
Rust is telling us that we forgot some value. The compiler infers from `x` that it
40+
can have any 32bit integer value; for example -2,147,483,648 to 2,147,483,647. The `_` acts
4141
as a 'catch-all', and will catch all possible values that *aren't* specified in
42-
an arm of `match`. As you can see with the previous example, we provide `match`
42+
an arm of `match`. As you can see in the previous example, we provide `match`
4343
arms for integers 1-5, if `x` is 6 or any other value, then it is caught by `_`.
4444

4545
`match` is also an expression, which means we can use it on the right-hand

src/doc/book/primitive-types.md

+4-4
Original file line numberDiff line numberDiff line change
@@ -7,7 +7,7 @@ of these ones, as well, but these are the most primitive.
77

88
# Booleans
99

10-
Rust has a built in boolean type, named `bool`. It has two values, `true` and `false`:
10+
Rust has a built-in boolean type, named `bool`. It has two values, `true` and `false`:
1111

1212
```rust
1313
let x = true;
@@ -89,13 +89,13 @@ Unsigned types use a `u` for their category, and signed types use `i`. The `i`
8989
is for ‘integer’. So `u8` is an eight-bit unsigned number, and `i8` is an
9090
eight-bit signed number.
9191

92-
## Fixed size types
92+
## Fixed-size types
9393

94-
Fixed size types have a specific number of bits in their representation. Valid
94+
Fixed-size types have a specific number of bits in their representation. Valid
9595
bit sizes are `8`, `16`, `32`, and `64`. So, `u32` is an unsigned, 32-bit integer,
9696
and `i64` is a signed, 64-bit integer.
9797

98-
## Variable sized types
98+
## Variable-size types
9999

100100
Rust also provides types whose size depends on the size of a pointer of the
101101
underlying machine. These types have ‘size’ as the category, and come in signed

src/doc/book/references-and-borrowing.md

+1-1
Original file line numberDiff line numberDiff line change
@@ -212,7 +212,7 @@ fn main() {
212212

213213
In other words, the mutable borrow is held through the rest of our example. What
214214
we want is for the mutable borrow by `y` to end so that the resource can be
215-
returned to the owner, `x`. `x` can then provide a mutable borrow to `println!`.
215+
returned to the owner, `x`. `x` can then provide a immutable borrow to `println!`.
216216
In Rust, borrowing is tied to the scope that the borrow is valid for. And our
217217
scopes look like this:
218218

src/libcore/cmp.rs

+35
Original file line numberDiff line numberDiff line change
@@ -14,6 +14,21 @@
1414
//! by the compiler to implement comparison operators. Rust programs may
1515
//! implement `PartialOrd` to overload the `<`, `<=`, `>`, and `>=` operators,
1616
//! and may implement `PartialEq` to overload the `==` and `!=` operators.
17+
//!
18+
//! # Examples
19+
//!
20+
//! ```
21+
//! let x: u32 = 0;
22+
//! let y: u32 = 1;
23+
//!
24+
//! // these two lines are equivalent
25+
//! assert_eq!(x < y, true);
26+
//! assert_eq!(x.lt(&y), true);
27+
//!
28+
//! // these two lines are also equivalent
29+
//! assert_eq!(x == y, false);
30+
//! assert_eq!(x.eq(&y), false);
31+
//! ```
1732
1833
#![stable(feature = "rust1", since = "1.0.0")]
1934

@@ -44,6 +59,16 @@ use option::Option::{self, Some};
4459
/// only if `a != b`.
4560
///
4661
/// This trait can be used with `#[derive]`.
62+
///
63+
/// # Examples
64+
///
65+
/// ```
66+
/// let x: u32 = 0;
67+
/// let y: u32 = 1;
68+
///
69+
/// assert_eq!(x == y, false);
70+
/// assert_eq!(x.eq(&y), false);
71+
/// ```
4772
#[lang = "eq"]
4873
#[stable(feature = "rust1", since = "1.0.0")]
4974
pub trait PartialEq<Rhs: ?Sized = Self> {
@@ -226,6 +251,16 @@ impl PartialOrd for Ordering {
226251
///
227252
/// This trait can be used with `#[derive]`. When `derive`d, it will produce an ordering
228253
/// based on the top-to-bottom declaration order of the struct's members.
254+
///
255+
/// # Examples
256+
///
257+
/// ```
258+
/// let x : u32 = 0;
259+
/// let y : u32 = 1;
260+
///
261+
/// assert_eq!(x < y, true);
262+
/// assert_eq!(x.lt(&y), true);
263+
/// ```
229264
#[lang = "ord"]
230265
#[stable(feature = "rust1", since = "1.0.0")]
231266
pub trait PartialOrd<Rhs: ?Sized = Self>: PartialEq<Rhs> {

src/librustc_typeck/diagnostics.rs

+2-2
Original file line numberDiff line numberDiff line change
@@ -3167,8 +3167,8 @@ x <<= 2;
31673167
To fix this error, please check that this type implements this binary
31683168
operation. Example:
31693169
3170-
```compile_fail
3171-
let x = 12u32; // the `u32` type does implement the `ShlAssign` trait
3170+
```
3171+
let mut x = 12u32; // the `u32` type does implement the `ShlAssign` trait
31723172
31733173
x <<= 2; // ok!
31743174
```

0 commit comments

Comments
 (0)