]> git.lizzy.rs Git - rust.git/blob - tests/ui/floating_point_rad.rs
Auto merge of #8374 - Alexendoo:bless-revisions, r=camsteffen
[rust.git] / tests / ui / floating_point_rad.rs
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 fn main() {
12     let x = 3f32;
13     let _ = x * 180f32 / std::f32::consts::PI;
14     let _ = 90. * 180f64 / std::f64::consts::PI;
15     let _ = 90.5 * 180f64 / std::f64::consts::PI;
16     let _ = x * std::f32::consts::PI / 180f32;
17     let _ = 90. * std::f32::consts::PI / 180f32;
18     let _ = 90.5 * std::f32::consts::PI / 180f32;
19     // let _ = 90.5 * 80. * std::f32::consts::PI / 180f32;
20     // Cases where the lint shouldn't be applied
21     let _ = x * 90f32 / std::f32::consts::PI;
22     let _ = x * std::f32::consts::PI / 90f32;
23     let _ = x * 180f32 / std::f32::consts::E;
24     let _ = x * std::f32::consts::E / 180f32;
25 }