3 #![feature(custom_inner_attributes)]
5 #![warn(clippy::cast_lossless)]
8 // Test clippy::cast_lossless with casts to integer types
14 let _ = true as usize;
21 let _ = true as isize;
23 // Test with an expression wrapped in parens
24 let _ = (true | false) as u16;
27 // The lint would suggest using `u32::from(input)` here but the `XX::from` function is not const,
28 // so we skip the lint if the expression is in a const fn.
30 const fn abc(input: bool) -> u32 {
34 // Same as the above issue. We can't suggest `::from` in const fns in impls
35 mod cast_lossless_in_impl {
39 pub const fn convert(x: bool) -> u64 {
46 #![clippy::msrv = "1.27"]
52 #![clippy::msrv = "1.28"]