Skip to content

Commit f20a076

Browse files
committed
Check more constant forms in float_cmp
1 parent b794b8e commit f20a076

File tree

1 file changed

+9
-3
lines changed

1 file changed

+9
-3
lines changed

clippy_lints/src/operators/float_cmp.rs

Lines changed: 9 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -86,13 +86,19 @@ fn get_lint_and_message(is_local: bool, is_comparing_arrays: bool) -> (&'static
8686
fn is_allowed(val: &Constant<'_>) -> bool {
8787
match val {
8888
// FIXME(f16_f128): add when equality check is available on all platforms
89+
Constant::Ref(val) => is_allowed(val),
8990
&Constant::F32(f) => f == 0.0 || f.is_infinite(),
9091
&Constant::F64(f) => f == 0.0 || f.is_infinite(),
91-
Constant::Vec(vec) => vec.iter().all(|f| match f {
92-
Constant::F32(f) => *f == 0.0 || (*f).is_infinite(),
93-
Constant::F64(f) => *f == 0.0 || (*f).is_infinite(),
92+
Constant::Vec(vec) => vec.iter().all(|f| match *f {
93+
Constant::F32(f) => f == 0.0 || f.is_infinite(),
94+
Constant::F64(f) => f == 0.0 || f.is_infinite(),
9495
_ => false,
9596
}),
97+
Constant::Repeat(val, _) => match **val {
98+
Constant::F32(f) => f == 0.0 || f.is_infinite(),
99+
Constant::F64(f) => f == 0.0 || f.is_infinite(),
100+
_ => false,
101+
},
96102
_ => false,
97103
}
98104
}

0 commit comments

Comments
 (0)