summaryrefslogtreecommitdiffstats
path: root/src/tools/clippy/src/docs/default_numeric_fallback.txt
blob: 15076a0a68bf6717c884c45cd79bb90f076b1700 (plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
### What it does
Checks for usage of unconstrained numeric literals which may cause default numeric fallback in type
inference.

Default numeric fallback means that if numeric types have not yet been bound to concrete
types at the end of type inference, then integer type is bound to `i32`, and similarly
floating type is bound to `f64`.

See [RFC0212](https://github.com/rust-lang/rfcs/blob/master/text/0212-restore-int-fallback.md) for more information about the fallback.

### Why is this bad?
For those who are very careful about types, default numeric fallback
can be a pitfall that cause unexpected runtime behavior.

### Known problems
This lint can only be allowed at the function level or above.

### Example
```
let i = 10;
let f = 1.23;
```

Use instead:
```
let i = 10i32;
let f = 1.23f64;
```