Skip to content

Commit 4c82661

Browse files
committed
Fix test now that overflowing_literals is rejected in all editions.
The default for mdbook is 2015, so this was testing old behavior. Now that overflowing_literals is deny-by-default on all editions, the test was failing. This updates for the new behavior.
1 parent a13c42d commit 4c82661

File tree

1 file changed

+8
-8
lines changed

1 file changed

+8
-8
lines changed

src/rust-2018/data-types/inclusive-ranges.md

Lines changed: 8 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -25,7 +25,7 @@ three is included in the range. Inclusive ranges are especially useful if you
2525
want to iterate over every possible value in a range. For example, this is a
2626
surprising Rust program:
2727

28-
```rust
28+
```rust,compile_fail
2929
fn takes_u8(x: u8) {
3030
// ...
3131
}
@@ -38,21 +38,21 @@ fn main() {
3838
}
3939
```
4040

41-
What does this program do? The answer: nothing. The warning we get when
42-
compiling has a hint:
41+
What does this program do? The answer: it fails to compile. The error we get
42+
when compiling has a hint:
4343

4444
```text
45-
warning: literal out of range for u8
45+
error: literal out of range for u8
4646
--> src/main.rs:6:17
4747
|
4848
6 | for i in 0..256 {
4949
| ^^^
5050
|
51-
= note: #[warn(overflowing_literals)] on by default
51+
= note: #[deny(overflowing_literals)] on by default
5252
```
5353

54-
That’s right, since `i` is a `u8`, this overflows, and is the same as writing
55-
`for i in 0..0`, so the loop executes zero times.
54+
That’s right, since `i` is a `u8`, this overflows, and the compiler produces
55+
an error.
5656

5757
We can do this with inclusive ranges, however:
5858

@@ -69,4 +69,4 @@ fn main() {
6969
}
7070
```
7171

72-
This will produce those 256 lines of output you might have been expecting.
72+
This will produce those 256 lines of output you might have been expecting.

0 commit comments

Comments
 (0)