Skip to content

Commit 012e207

Browse files
Literal expressions: add a Note describing the overflowing_literals lint
1 parent 11af6b8 commit 012e207

File tree

1 file changed

+4
-0
lines changed

1 file changed

+4
-0
lines changed

src/expressions/literal-expr.md

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -74,6 +74,9 @@ If the value does not fit in `u128`, the expression is rejected by the parser.
7474

7575
* The `u128` value is converted to the expression's type via a [numeric cast].
7676

77+
> **Note**: The final cast will truncate the value of the literal if it does not fit in the expression's type.
78+
> There is a [lint check] named `overflowing_literals`, defaulting to `deny`, which rejects expressions where this occurs.
79+
7780
## Floating-point literal expressions
7881

7982
A floating-point literal expression consists of a single [FLOAT_LITERAL] token.
@@ -101,6 +104,7 @@ let x: f64 = 2.; // type f64
101104

102105
[constant expression]: ../const_eval.md#constant-expressions
103106
[floating-point types]: ../types/numeric.md#floating-point-types
107+
[lint check]: ../attributes/diagnostics.md#lint-check-attributes
104108
[literal tokens]: ../tokens.md#literals
105109
[numeric cast]: operator-expr.md#numeric-cast
106110
[numeric types]: ../types/numeric.md

0 commit comments

Comments
 (0)