]> git.lizzy.rs Git - rust.git/blob - src/docs/default_numeric_fallback.txt
Auto merge of #9475 - Nemo157:mod-files-remap, r=xFrednet
[rust.git] / src / docs / default_numeric_fallback.txt
1 ### What it does
2 Checks for usage of unconstrained numeric literals which may cause default numeric fallback in type
3 inference.
4
5 Default numeric fallback means that if numeric types have not yet been bound to concrete
6 types at the end of type inference, then integer type is bound to `i32`, and similarly
7 floating type is bound to `f64`.
8
9 See [RFC0212](https://github.com/rust-lang/rfcs/blob/master/text/0212-restore-int-fallback.md) for more information about the fallback.
10
11 ### Why is this bad?
12 For those who are very careful about types, default numeric fallback
13 can be a pitfall that cause unexpected runtime behavior.
14
15 ### Known problems
16 This lint can only be allowed at the function level or above.
17
18 ### Example
19 ```
20 let i = 10;
21 let f = 1.23;
22 ```
23
24 Use instead:
25 ```
26 let i = 10i32;
27 let f = 1.23f64;
28 ```