Skip to content

Commit 8c7d8b1

Browse files
authored
Merge pull request #1970 from moseswynn/overflowing-literals-clarification
add clarification on overflowing_literals lint
2 parents 3256791 + ae88a08 commit 8c7d8b1

File tree

1 file changed

+3
-2
lines changed

1 file changed

+3
-2
lines changed

src/types/cast.md

Lines changed: 3 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -8,7 +8,7 @@ except in cases where C has undefined behavior. The behavior of all casts
88
between integral types is well defined in Rust.
99

1010
```rust,editable,ignore,mdbook-runnable
11-
// Suppress all warnings from casts which overflow.
11+
// Suppress all errors from casts which overflow.
1212
#![allow(overflowing_literals)]
1313
1414
fn main() {
@@ -31,7 +31,8 @@ fn main() {
3131
3232
// when casting any value to an unsigned type, T,
3333
// T::MAX + 1 is added or subtracted until the value
34-
// fits into the new type
34+
// fits into the new type ONLY when the #![allow(overflowing_literals)]
35+
// lint is specified like above. Otherwise there will be a compiler error.
3536
3637
// 1000 already fits in a u16
3738
println!("1000 as a u16 is: {}", 1000 as u16);

0 commit comments

Comments
 (0)