Skip to content

Commit

Permalink
#![allow(clippy::float_cmp)] everywhere
Browse files Browse the repository at this point in the history
it has always been an annoyance, never a help
  • Loading branch information
emilk committed May 9, 2021
1 parent 6ad6f56 commit fb5176c
Show file tree
Hide file tree
Showing 14 changed files with 7 additions and 24 deletions.
2 changes: 1 addition & 1 deletion egui/src/containers/scroll_area.rs
Original file line number Diff line number Diff line change
Expand Up @@ -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;
}
Expand Down
1 change: 1 addition & 0 deletions egui/src/lib.rs
Original file line number Diff line number Diff line change
Expand Up @@ -294,6 +294,7 @@
nonstandard_style,
rust_2018_idioms
)]
#![allow(clippy::float_cmp)]
#![allow(clippy::manual_range_contains)]

mod animation_manager;
Expand Down
4 changes: 0 additions & 4 deletions egui/src/ui.rs
Original file line number Diff line number Diff line change
Expand Up @@ -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("°"));

Expand All @@ -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;
Expand Down
5 changes: 1 addition & 4 deletions egui/src/widgets/drag_value.rs
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand Down
1 change: 0 additions & 1 deletion egui/src/widgets/plot/mod.rs
Original file line number Diff line number Diff line change
Expand Up @@ -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;
Expand Down
1 change: 0 additions & 1 deletion egui/src/widgets/slider.rs
Original file line number Diff line number Diff line change
@@ -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;
Expand Down
1 change: 1 addition & 0 deletions egui_demo_lib/src/lib.rs
Original file line number Diff line number Diff line change
Expand Up @@ -55,6 +55,7 @@
nonstandard_style,
rust_2018_idioms
)]
#![allow(clippy::float_cmp)]
#![allow(clippy::manual_range_contains)]

mod apps;
Expand Down
2 changes: 0 additions & 2 deletions egui_demo_lib/src/wrap_app.rs
Original file line number Diff line number Diff line change
Expand Up @@ -335,8 +335,6 @@ impl BackendPanel {
ui: &mut egui::Ui,
info: &epi::IntegrationInfo,
) -> Option<f32> {
#![allow(clippy::float_cmp)]

self.pixels_per_point = self
.pixels_per_point
.or(info.native_pixels_per_point)
Expand Down
6 changes: 1 addition & 5 deletions emath/src/lib.rs
Original file line number Diff line number Diff line change
Expand Up @@ -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};
Expand Down Expand Up @@ -141,7 +142,6 @@ pub fn remap<T>(x: T, from: RangeInclusive<T>, to: RangeInclusive<T>) -> 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)
Expand All @@ -152,7 +152,6 @@ pub fn remap_clamp<T>(x: T, from: RangeInclusive<T>, to: RangeInclusive<T>) -> 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());
}
Expand Down Expand Up @@ -235,8 +234,6 @@ pub fn format_with_decimals_in_range(value: f64, decimal_range: RangeInclusive<u
/// The `epsilon` can be `f32::EPSILON` to handle simple transforms (like degrees -> 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 {
Expand Down Expand Up @@ -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);
Expand Down
2 changes: 0 additions & 2 deletions emath/src/smart_aim.rs
Original file line number Diff line number Diff line change
@@ -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.
Expand Down
2 changes: 0 additions & 2 deletions emath/src/vec2.rs
Original file line number Diff line number Diff line change
Expand Up @@ -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;
Expand Down
2 changes: 0 additions & 2 deletions epaint/src/color.rs
Original file line number Diff line number Diff line change
Expand Up @@ -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);
Expand Down Expand Up @@ -613,7 +612,6 @@ impl From<Color32> 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
Expand Down
1 change: 1 addition & 0 deletions epaint/src/lib.rs
Original file line number Diff line number Diff line change
Expand Up @@ -53,6 +53,7 @@
nonstandard_style,
rust_2018_idioms
)]
#![allow(clippy::float_cmp)]
#![allow(clippy::manual_range_contains)]

pub mod color;
Expand Down
1 change: 1 addition & 0 deletions epi/src/lib.rs
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand Down

0 comments on commit fb5176c

Please sign in to comment.