Skip to content

Commit 74f5090

Browse files
committed
Allow for const arrays of zeros
1 parent 0766002 commit 74f5090

File tree

1 file changed

+5
-0
lines changed

1 file changed

+5
-0
lines changed

clippy_lints/src/misc.rs

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -477,6 +477,11 @@ fn is_allowed<'a, 'tcx>(cx: &LateContext<'a, 'tcx>, expr: &'tcx Expr<'_>) -> boo
477477
match constant(cx, cx.tables, expr) {
478478
Some((Constant::F32(f), _)) => f == 0.0 || f.is_infinite(),
479479
Some((Constant::F64(f), _)) => f == 0.0 || f.is_infinite(),
480+
Some((Constant::Vec(vec), _)) => vec.iter().all(|f| match f {
481+
Constant::F32(f) => *f == 0.0 || (*f).is_infinite(),
482+
Constant::F64(f) => *f == 0.0 || (*f).is_infinite(),
483+
_ => false,
484+
}),
480485
_ => false,
481486
}
482487
}

0 commit comments

Comments
 (0)