From 01f8c4336b4325b6d6926150c000bfa162aceb47 Mon Sep 17 00:00:00 2001 From: Emil Ernerfeldt Date: Mon, 12 Dec 2022 15:48:59 +0100 Subject: [PATCH] Revert "fix all clippy lints and remove them from allow list in cranky (#2419)" This reverts commit 930ef2db3817cc7104c5f6ab81dcc9ddb219a1d7. --- Cranky.toml | 5 +++++ crates/ecolor/src/color32.rs | 2 +- crates/ecolor/src/lib.rs | 2 +- crates/ecolor/src/rgba.rs | 8 ++++---- crates/egui_demo_app/src/apps/custom3d_glow.rs | 11 ++++++----- 5 files changed, 17 insertions(+), 11 deletions(-) diff --git a/Cranky.toml b/Cranky.toml index 9e829f6b518..957bd477aa4 100644 --- a/Cranky.toml +++ b/Cranky.toml @@ -115,4 +115,9 @@ warn = [ allow = [ # TODO(emilk): enable more lints "clippy::type_complexity", + "clippy::undocumented_unsafe_blocks", + "clippy::manual_range_contains", + "trivial_casts", + "unsafe_op_in_unsafe_fn", # `unsafe_op_in_unsafe_fn` may become the default in future Rust versions: https://github.com/rust-lang/rust/issues/71668 + "unused_qualifications", ] diff --git a/crates/ecolor/src/color32.rs b/crates/ecolor/src/color32.rs index 9842001c05d..ee22c4d047c 100644 --- a/crates/ecolor/src/color32.rs +++ b/crates/ecolor/src/color32.rs @@ -173,7 +173,7 @@ impl Color32 { /// Multiply with 0.5 to make color half as opaque. pub fn linear_multiply(self, factor: f32) -> Color32 { - crate::ecolor_assert!((0.0..=1.0).contains(&factor)); + crate::ecolor_assert!(0.0 <= factor && factor <= 1.0); // As an unfortunate side-effect of using premultiplied alpha // we need a somewhat expensive conversion to linear space and back. Rgba::from(self).multiply(factor).into() diff --git a/crates/ecolor/src/lib.rs b/crates/ecolor/src/lib.rs index 82735054dc7..9bc42c4cf79 100644 --- a/crates/ecolor/src/lib.rs +++ b/crates/ecolor/src/lib.rs @@ -100,7 +100,7 @@ fn fast_round(r: f32) -> u8 { pub fn test_srgba_conversion() { for b in 0..=255 { let l = linear_f32_from_gamma_u8(b); - assert!((0.0..=1.0).contains(&l)); + assert!(0.0 <= l && l <= 1.0); assert_eq!(gamma_u8_from_linear_f32(l), b); } } diff --git a/crates/ecolor/src/rgba.rs b/crates/ecolor/src/rgba.rs index 6584e3af1f3..f9d671fd5c1 100644 --- a/crates/ecolor/src/rgba.rs +++ b/crates/ecolor/src/rgba.rs @@ -96,22 +96,22 @@ impl Rgba { } pub fn from_luminance_alpha(l: f32, a: f32) -> Self { - crate::ecolor_assert!((0.0..=1.0).contains(&l)); - crate::ecolor_assert!((0.0..=1.0).contains(&a)); + crate::ecolor_assert!(0.0 <= l && l <= 1.0); + crate::ecolor_assert!(0.0 <= a && a <= 1.0); Self([l * a, l * a, l * a, a]) } /// Transparent black #[inline(always)] pub fn from_black_alpha(a: f32) -> Self { - crate::ecolor_assert!((0.0..=1.0).contains(&a)); + crate::ecolor_assert!(0.0 <= a && a <= 1.0); Self([0.0, 0.0, 0.0, a]) } /// Transparent white #[inline(always)] pub fn from_white_alpha(a: f32) -> Self { - crate::ecolor_assert!((0.0..=1.0).contains(&a), "a: {}", a); + crate::ecolor_assert!(0.0 <= a && a <= 1.0, "a: {}", a); Self([a, a, a, a]) } diff --git a/crates/egui_demo_app/src/apps/custom3d_glow.rs b/crates/egui_demo_app/src/apps/custom3d_glow.rs index d5b4f2603aa..5d82d75c244 100644 --- a/crates/egui_demo_app/src/apps/custom3d_glow.rs +++ b/crates/egui_demo_app/src/apps/custom3d_glow.rs @@ -146,11 +146,12 @@ impl RotatingTriangle { ), ); gl.compile_shader(shader); - assert!( - gl.get_shader_compile_status(shader), - "Failed to compile custom_3d_glow: {}", - gl.get_shader_info_log(shader) - ); + if !gl.get_shader_compile_status(shader) { + panic!( + "Failed to compile custom_3d_glow: {}", + gl.get_shader_info_log(shader) + ); + } gl.attach_shader(program, shader); shader })