fork/rust
git clone https://git.julia.blue/fork/rust
3bcad65fbf6
master
1#![feature(const_fn_floating_point_arithmetic)] 2#![warn(clippy::suboptimal_flops)] 3 4/// Allow suboptimal_flops in constant context 5pub const fn const_context() { 6 let x = 3f32; 7 let _ = x * 180f32 / std::f32::consts::PI; 8} 9 10pub fn issue9391(degrees: i64) { 11 let _ = (degrees as f64).to_radians(); 12 let _ = (degrees as f64).to_degrees(); 13} 14 15fn main() { 16 let x = 3f32; 17 let _ = x.to_degrees(); 18 let _ = 90.0_f64.to_degrees(); 19 let _ = 90.5_f64.to_degrees(); 20 let _ = x.to_radians(); 21 let _ = 90.0_f64.to_radians(); 22 let _ = 90.5_f64.to_radians(); 23 // let _ = 90.5 * 80. * std::f32::consts::PI / 180f32; 24 // Cases where the lint shouldn't be applied 25 let _ = x * 90f32 / std::f32::consts::PI; 26 let _ = x * std::f32::consts::PI / 90f32; 27 let _ = x * 180f32 / std::f32::consts::E; 28 let _ = x * std::f32::consts::E / 180f32; 29}