]>
Commit | Line | Data |
---|---|---|
a2a8927a | 1 | #![feature(const_fn_floating_point_arithmetic)] |
f20569fa XL |
2 | #![warn(clippy::suboptimal_flops)] |
3 | ||
a2a8927a XL |
4 | /// Allow suboptimal_flops in constant context |
5 | pub const fn const_context() { | |
6 | let x = 3f32; | |
7 | let _ = x * 180f32 / std::f32::consts::PI; | |
8 | } | |
9 | ||
f2b60f7d FG |
10 | pub fn issue9391(degrees: i64) { |
11 | let _ = (degrees as f64).to_radians(); | |
12 | let _ = (degrees as f64).to_degrees(); | |
13 | } | |
14 | ||
f20569fa XL |
15 | fn main() { |
16 | let x = 3f32; | |
17 | let _ = x.to_degrees(); | |
a2a8927a XL |
18 | let _ = 90.0_f64.to_degrees(); |
19 | let _ = 90.5_f64.to_degrees(); | |
f20569fa | 20 | let _ = x.to_radians(); |
a2a8927a XL |
21 | let _ = 90.0_f64.to_radians(); |
22 | let _ = 90.5_f64.to_radians(); | |
23 | // let _ = 90.5 * 80. * std::f32::consts::PI / 180f32; | |
f20569fa XL |
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 | } |