Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

enable manual_range_contains lint #5214

Closed
wants to merge 1 commit into from
Closed
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
2 changes: 1 addition & 1 deletion Cargo.toml
Original file line number Diff line number Diff line change
Expand Up @@ -181,6 +181,7 @@ manual_clamp = "warn"
manual_instant_elapsed = "warn"
manual_let_else = "warn"
manual_ok_or = "warn"
manual_range_contains = "warn"
manual_string_new = "warn"
map_err_ignore = "warn"
map_flatten = "warn"
Expand Down Expand Up @@ -261,6 +262,5 @@ should_panic_without_expect = "allow"
too_many_lines = "allow"
unwrap_used = "allow" # TODO(emilk): We really wanna warn on this one

manual_range_contains = "allow" # this one is just worse imho
self_named_module_files = "allow" # Disabled waiting on https://github.com/rust-lang/rust-clippy/issues/9602
significant_drop_tightening = "allow" # Too many false positives
2 changes: 1 addition & 1 deletion crates/ecolor/src/lib.rs
Original file line number Diff line number Diff line change
Expand Up @@ -104,7 +104,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 @@ -98,22 +98,22 @@ impl Rgba {

#[inline]
pub fn from_luminance_alpha(l: f32, a: f32) -> Self {
debug_assert!(0.0 <= l && l <= 1.0);
debug_assert!(0.0 <= a && a <= 1.0);
debug_assert!((0.0..=1.0).contains(&l));
debug_assert!((0.0..=1.0).contains(&a));
Self([l * a, l * a, l * a, a])
}

/// Transparent black
#[inline]
pub fn from_black_alpha(a: f32) -> Self {
debug_assert!(0.0 <= a && a <= 1.0);
debug_assert!((0.0..=1.0).contains(&a));
Self([0.0, 0.0, 0.0, a])
}

/// Transparent white
#[inline]
pub fn from_white_alpha(a: f32) -> Self {
debug_assert!(0.0 <= a && a <= 1.0, "a: {a}");
debug_assert!((0.0..=1.0).contains(&a), "a: {a}");
Self([a, a, a, a])
}

Expand Down
Loading