]> git.lizzy.rs Git - rust.git/blob - src/docs/as_underscore.txt
Auto merge of #9421 - xphoniex:fix-#9420, r=giraffate
[rust.git] / src / docs / as_underscore.txt
1 ### What it does
2 Check for the usage of `as _` conversion using inferred type.
3
4 ### Why is this bad?
5 The conversion might include lossy conversion and dangerous cast that might go
6 undetected due to the type being inferred.
7
8 The lint is allowed by default as using `_` is less wordy than always specifying the type.
9
10 ### Example
11 ```
12 fn foo(n: usize) {}
13 let n: u16 = 256;
14 foo(n as _);
15 ```
16 Use instead:
17 ```
18 fn foo(n: usize) {}
19 let n: u16 = 256;
20 foo(n as usize);
21 ```