]> git.lizzy.rs Git - rust.git/blob - tests/ui/floating_point_rad.fixed
Auto merge of #9684 - kraktus:ref_option_ref, r=xFrednet
[rust.git] / tests / ui / floating_point_rad.fixed
1 // run-rustfix
2 #![feature(const_fn_floating_point_arithmetic)]
3 #![warn(clippy::suboptimal_flops)]
4
5 /// Allow suboptimal_flops in constant context
6 pub const fn const_context() {
7     let x = 3f32;
8     let _ = x * 180f32 / std::f32::consts::PI;
9 }
10
11 pub fn issue9391(degrees: i64) {
12     let _ = (degrees as f64).to_radians();
13     let _ = (degrees as f64).to_degrees();
14 }
15
16 fn main() {
17     let x = 3f32;
18     let _ = x.to_degrees();
19     let _ = 90.0_f64.to_degrees();
20     let _ = 90.5_f64.to_degrees();
21     let _ = x.to_radians();
22     let _ = 90.0_f64.to_radians();
23     let _ = 90.5_f64.to_radians();
24     // let _ = 90.5 * 80. * std::f32::consts::PI / 180f32;
25     // Cases where the lint shouldn't be applied
26     let _ = x * 90f32 / std::f32::consts::PI;
27     let _ = x * std::f32::consts::PI / 90f32;
28     let _ = x * 180f32 / std::f32::consts::E;
29     let _ = x * std::f32::consts::E / 180f32;
30 }