From fb5176c1331c466c92e9240fab74fb9e1555190c Mon Sep 17 00:00:00 2001 From: Emil Ernerfeldt Date: Sun, 9 May 2021 14:00:53 +0200 Subject: [PATCH] #![allow(clippy::float_cmp)] everywhere it has always been an annoyance, never a help --- egui/src/containers/scroll_area.rs | 2 +- egui/src/lib.rs | 1 + egui/src/ui.rs | 4 ---- egui/src/widgets/drag_value.rs | 5 +---- egui/src/widgets/plot/mod.rs | 1 - egui/src/widgets/slider.rs | 1 - egui_demo_lib/src/lib.rs | 1 + egui_demo_lib/src/wrap_app.rs | 2 -- emath/src/lib.rs | 6 +----- emath/src/smart_aim.rs | 2 -- emath/src/vec2.rs | 2 -- epaint/src/color.rs | 2 -- epaint/src/lib.rs | 1 + epi/src/lib.rs | 1 + 14 files changed, 7 insertions(+), 24 deletions(-) diff --git a/egui/src/containers/scroll_area.rs b/egui/src/containers/scroll_area.rs index 09edce67..1e99e831 100644 --- a/egui/src/containers/scroll_area.rs +++ b/egui/src/containers/scroll_area.rs @@ -301,7 +301,7 @@ impl Prepared { let unbounded_offset_y = state.offset.y; state.offset.y = state.offset.y.max(0.0); state.offset.y = state.offset.y.min(max_offset); - #[allow(clippy::float_cmp)] + if state.offset.y != unbounded_offset_y { state.vel = Vec2::ZERO; } diff --git a/egui/src/lib.rs b/egui/src/lib.rs index 56a3d9e6..b9191fa8 100644 --- a/egui/src/lib.rs +++ b/egui/src/lib.rs @@ -294,6 +294,7 @@ nonstandard_style, rust_2018_idioms )] +#![allow(clippy::float_cmp)] #![allow(clippy::manual_range_contains)] mod animation_manager; diff --git a/egui/src/ui.rs b/egui/src/ui.rs index 0d528b3b..39202266 100644 --- a/egui/src/ui.rs +++ b/egui/src/ui.rs @@ -1055,8 +1055,6 @@ impl Ui { /// Modify an angle. The given angle should be in radians, but is shown to the user in degrees. /// The angle is NOT wrapped, so the user may select, for instance 720° = 2𝞃 = 4π pub fn drag_angle(&mut self, radians: &mut f32) -> Response { - #![allow(clippy::float_cmp)] - let mut degrees = radians.to_degrees(); let mut response = self.add(DragValue::new(&mut degrees).speed(1.0).suffix("°")); @@ -1073,8 +1071,6 @@ impl Ui { /// but is shown to the user in fractions of one Tau (i.e. fractions of one turn). /// The angle is NOT wrapped, so the user may select, for instance 2𝞃 (720°) pub fn drag_angle_tau(&mut self, radians: &mut f32) -> Response { - #![allow(clippy::float_cmp)] - use std::f32::consts::TAU; let mut taus = *radians / TAU; diff --git a/egui/src/widgets/drag_value.rs b/egui/src/widgets/drag_value.rs index d9cd31f1..ef2a97b3 100644 --- a/egui/src/widgets/drag_value.rs +++ b/egui/src/widgets/drag_value.rs @@ -334,10 +334,7 @@ impl<'a> Widget for DragValue<'a> { response }; - #[allow(clippy::float_cmp)] - { - response.changed = get(&mut get_set_value) != value; - } + response.changed = get(&mut get_set_value) != value; response.widget_info(|| WidgetInfo::drag_value(value)); response diff --git a/egui/src/widgets/plot/mod.rs b/egui/src/widgets/plot/mod.rs index 39a38aa9..12e7664f 100644 --- a/egui/src/widgets/plot/mod.rs +++ b/egui/src/widgets/plot/mod.rs @@ -423,7 +423,6 @@ impl Widget for Plot { } else { ui.input().zoom_delta_2d() }; - #[allow(clippy::float_cmp)] if zoom_factor != Vec2::splat(1.0) { transform.zoom(zoom_factor, hover_pos); auto_bounds = false; diff --git a/egui/src/widgets/slider.rs b/egui/src/widgets/slider.rs index 73a44756..f24c216d 100644 --- a/egui/src/widgets/slider.rs +++ b/egui/src/widgets/slider.rs @@ -1,5 +1,4 @@ #![allow(clippy::needless_pass_by_value)] // False positives with `impl ToString` -#![allow(clippy::float_cmp)] use crate::{widgets::Label, *}; use std::ops::RangeInclusive; diff --git a/egui_demo_lib/src/lib.rs b/egui_demo_lib/src/lib.rs index 67f5c675..3ea41ab9 100644 --- a/egui_demo_lib/src/lib.rs +++ b/egui_demo_lib/src/lib.rs @@ -55,6 +55,7 @@ nonstandard_style, rust_2018_idioms )] +#![allow(clippy::float_cmp)] #![allow(clippy::manual_range_contains)] mod apps; diff --git a/egui_demo_lib/src/wrap_app.rs b/egui_demo_lib/src/wrap_app.rs index 731ef337..8f7c080f 100644 --- a/egui_demo_lib/src/wrap_app.rs +++ b/egui_demo_lib/src/wrap_app.rs @@ -335,8 +335,6 @@ impl BackendPanel { ui: &mut egui::Ui, info: &epi::IntegrationInfo, ) -> Option { - #![allow(clippy::float_cmp)] - self.pixels_per_point = self .pixels_per_point .or(info.native_pixels_per_point) diff --git a/emath/src/lib.rs b/emath/src/lib.rs index c29e048e..08f0154b 100644 --- a/emath/src/lib.rs +++ b/emath/src/lib.rs @@ -62,6 +62,7 @@ nonstandard_style, rust_2018_idioms )] +#![allow(clippy::float_cmp)] #![allow(clippy::manual_range_contains)] use std::ops::{Add, Div, Mul, RangeInclusive, Sub}; @@ -141,7 +142,6 @@ pub fn remap(x: T, from: RangeInclusive, to: RangeInclusive) -> T where T: Real, { - #![allow(clippy::float_cmp)] debug_assert!(from.start() != from.end()); let t = (x - *from.start()) / (*from.end() - *from.start()); lerp(to, t) @@ -152,7 +152,6 @@ pub fn remap_clamp(x: T, from: RangeInclusive, to: RangeInclusive) -> T where T: Real, { - #![allow(clippy::float_cmp)] if from.end() < from.start() { return remap_clamp(x, *from.end()..=*from.start(), *to.end()..=*to.start()); } @@ -235,8 +234,6 @@ pub fn format_with_decimals_in_range(value: f64, decimal_range: RangeInclusive radians) /// but should be higher to handle more complex transformations. pub fn almost_equal(a: f32, b: f32, epsilon: f32) -> bool { - #![allow(clippy::float_cmp)] - if a == b { true // handle infinites } else { @@ -292,7 +289,6 @@ fn test_almost_equal() { } } -#[allow(clippy::float_cmp)] #[test] fn test_remap() { assert_eq!(remap_clamp(1.0, 0.0..=1.0, 0.0..=16.0), 16.0); diff --git a/emath/src/smart_aim.rs b/emath/src/smart_aim.rs index f0768e03..c9b48d90 100644 --- a/emath/src/smart_aim.rs +++ b/emath/src/smart_aim.rs @@ -1,7 +1,5 @@ //! Find "simple" numbers is some range. Used by sliders. -#![allow(clippy::float_cmp)] // I know what I'm doing - const NUM_DECIMALS: usize = 15; /// Find the "simplest" number in a closed range [min, max], i.e. the one with the fewest decimal digits. diff --git a/emath/src/vec2.rs b/emath/src/vec2.rs index d6465704..cf926d64 100644 --- a/emath/src/vec2.rs +++ b/emath/src/vec2.rs @@ -422,8 +422,6 @@ impl std::fmt::Debug for Vec2 { #[test] fn test_vec2() { - #![allow(clippy::float_cmp)] - macro_rules! almost_eq { ($left:expr, $right:expr) => { let left = $left; diff --git a/epaint/src/color.rs b/epaint/src/color.rs index 13de4bfe..3ed144b1 100644 --- a/epaint/src/color.rs +++ b/epaint/src/color.rs @@ -414,7 +414,6 @@ pub fn linear_u8_from_linear_f32(a: f32) -> u8 { #[test] pub fn test_srgba_conversion() { - #![allow(clippy::float_cmp)] for b in 0..=255 { let l = linear_f32_from_gamma_u8(b); assert!(0.0 <= l && l <= 1.0); @@ -613,7 +612,6 @@ impl From for Hsva { /// All ranges in 0-1, rgb is linear. pub fn hsv_from_rgb([r, g, b]: [f32; 3]) -> (f32, f32, f32) { - #![allow(clippy::float_cmp)] #![allow(clippy::many_single_char_names)] let min = r.min(g.min(b)); let max = r.max(g.max(b)); // value diff --git a/epaint/src/lib.rs b/epaint/src/lib.rs index 36d0ebcb..63f01587 100644 --- a/epaint/src/lib.rs +++ b/epaint/src/lib.rs @@ -53,6 +53,7 @@ nonstandard_style, rust_2018_idioms )] +#![allow(clippy::float_cmp)] #![allow(clippy::manual_range_contains)] pub mod color; diff --git a/epi/src/lib.rs b/epi/src/lib.rs index 912028c7..1d2066ae 100644 --- a/epi/src/lib.rs +++ b/epi/src/lib.rs @@ -59,6 +59,7 @@ nonstandard_style, rust_2018_idioms )] +#![allow(clippy::float_cmp)] #![allow(clippy::manual_range_contains)] pub use egui; // Re-export for user convenience