Skip to content

Commit 1719573

Browse files
committed
Revise ...discriminants.range-patterns rule
Let's tighten up the text for this rule and condense it down into one sentence. It's a bit awkward to have another sentence just to say, "this is true even if...". Let's clean up the example as well.
1 parent 5408043 commit 1719573

File tree

1 file changed

+5
-5
lines changed

1 file changed

+5
-5
lines changed

src/types/closure.md

Lines changed: 5 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -354,14 +354,14 @@ c();
354354
```
355355

356356
r[type.closure.capture.precision.discriminants.range-patterns]
357-
Matching against a [range pattern][patterns.range] performs a read of the place being matched, causing the closure to borrow it by `ImmBorrow`. This is the case even if the range matches all possible values.
357+
Matching against a [range pattern][patterns.range] reads the place being matched, even if the range includes all possible values of the type, and captures the place by `ImmBorrow`.
358358

359-
```rust,compile_fail,E0506
360-
let mut x = 7_u8;
359+
```rust,compile_fail,E0502
360+
let mut x = 0u8;
361361
let c = || {
362-
let 0..=u8::MAX = x; // captures `x` by ImmBorrow
362+
let 0..=u8::MAX = x; // Captures `x` by `ImmBorrow`.
363363
};
364-
x += 1; // ERROR: cannot assign to `x` because it is borrowed
364+
let _ = &mut x; // ERROR: Cannot borrow `x` as mutable.
365365
c();
366366
```
367367

0 commit comments

Comments
 (0)