#![allow(clippy::float_cmp)] everywhere

it has always been an annoyance, never a help
This commit is contained in:
Emil Ernerfeldt 2021-05-09 14:00:53 +02:00
parent 6ad6f56cb1
commit fb5176c133
14 changed files with 7 additions and 24 deletions

View file

@ -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;
}

View file

@ -294,6 +294,7 @@
nonstandard_style,
rust_2018_idioms
)]
#![allow(clippy::float_cmp)]
#![allow(clippy::manual_range_contains)]
mod animation_manager;

View file

@ -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;

View file

@ -334,10 +334,7 @@ impl<'a> Widget for DragValue<'a> {
response
};
#[allow(clippy::float_cmp)]
{
response.changed = get(&mut get_set_value) != value;
}
response.widget_info(|| WidgetInfo::drag_value(value));
response

View file

@ -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;

View file

@ -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;

View file

@ -55,6 +55,7 @@
nonstandard_style,
rust_2018_idioms
)]
#![allow(clippy::float_cmp)]
#![allow(clippy::manual_range_contains)]
mod apps;

View file

@ -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)

View file

@ -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<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)
@ -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());
}
@ -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 {
@ -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);

View file

@ -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.

View file

@ -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;

View file

@ -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<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

View file

@ -53,6 +53,7 @@
nonstandard_style,
rust_2018_idioms
)]
#![allow(clippy::float_cmp)]
#![allow(clippy::manual_range_contains)]
pub mod color;

View file

@ -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