Skip to content

Commit

Permalink
fix all clippy lints and remove them from allow list in cranky (#2419)
Browse files Browse the repository at this point in the history
* manual range contains clippy lint removed from allow list
* removed multiple redundant allowed clippy lints
  • Loading branch information
coderedart authored Dec 11, 2022
1 parent 228f30e commit 930ef2d
Show file tree
Hide file tree
Showing 5 changed files with 11 additions and 17 deletions.
5 changes: 0 additions & 5 deletions Cranky.toml
Original file line number Diff line number Diff line change
Expand Up @@ -115,9 +115,4 @@ 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",
]
2 changes: 1 addition & 1 deletion crates/ecolor/src/color32.rs
Original file line number Diff line number Diff line change
Expand Up @@ -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 <= factor && factor <= 1.0);
crate::ecolor_assert!((0.0..=1.0).contains(&factor));
// 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()
Expand Down
2 changes: 1 addition & 1 deletion crates/ecolor/src/lib.rs
Original file line number Diff line number Diff line change
Expand Up @@ -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 <= l && l <= 1.0);
assert!((0.0..=1.0).contains(&l));
assert_eq!(gamma_u8_from_linear_f32(l), b);
}
}
Expand Down
8 changes: 4 additions & 4 deletions crates/ecolor/src/rgba.rs
Original file line number Diff line number Diff line change
Expand Up @@ -96,22 +96,22 @@ impl Rgba {
}

pub fn from_luminance_alpha(l: f32, a: f32) -> Self {
crate::ecolor_assert!(0.0 <= l && l <= 1.0);
crate::ecolor_assert!(0.0 <= a && a <= 1.0);
crate::ecolor_assert!((0.0..=1.0).contains(&l));
crate::ecolor_assert!((0.0..=1.0).contains(&a));
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 <= a && a <= 1.0);
crate::ecolor_assert!((0.0..=1.0).contains(&a));
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 <= a && a <= 1.0, "a: {}", a);
crate::ecolor_assert!((0.0..=1.0).contains(&a), "a: {}", a);
Self([a, a, a, a])
}

Expand Down
11 changes: 5 additions & 6 deletions crates/egui_demo_app/src/apps/custom3d_glow.rs
Original file line number Diff line number Diff line change
Expand Up @@ -146,12 +146,11 @@ impl RotatingTriangle {
),
);
gl.compile_shader(shader);
if !gl.get_shader_compile_status(shader) {
panic!(
"Failed to compile custom_3d_glow: {}",
gl.get_shader_info_log(shader)
);
}
assert!(
gl.get_shader_compile_status(shader),
"Failed to compile custom_3d_glow: {}",
gl.get_shader_info_log(shader)
);
gl.attach_shader(program, shader);
shader
})
Expand Down

0 comments on commit 930ef2d

Please sign in to comment.