]> git.lizzy.rs Git - rust.git/blob - tests/ui/cast_lossless_float.fixed
Auto merge of #3883 - daxpedda:missing_docs_in_private_items, r=phansch
[rust.git] / tests / ui / cast_lossless_float.fixed
1 // run-rustfix
2
3 #![allow(clippy::no_effect, clippy::unnecessary_operation, dead_code)]
4 #![warn(clippy::cast_lossless)]
5
6 fn main() {
7     // Test clippy::cast_lossless with casts to floating-point types
8     let x0 = 1i8;
9     f32::from(x0);
10     f64::from(x0);
11     let x1 = 1u8;
12     f32::from(x1);
13     f64::from(x1);
14     let x2 = 1i16;
15     f32::from(x2);
16     f64::from(x2);
17     let x3 = 1u16;
18     f32::from(x3);
19     f64::from(x3);
20     let x4 = 1i32;
21     f64::from(x4);
22     let x5 = 1u32;
23     f64::from(x5);
24 }
25
26 // The lint would suggest using `f64::from(input)` here but the `XX::from` function is not const,
27 // so we skip the lint if the expression is in a const fn.
28 // See #3656
29 const fn abc(input: f32) -> f64 {
30     input as f64
31 }