Skip to content

Commit bcbb9d9

Browse files
committed
Allow for const arrays of zeros
1 parent 6217671 commit bcbb9d9

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
@@ -475,6 +475,11 @@ fn is_allowed<'a, 'tcx>(cx: &LateContext<'a, 'tcx>, expr: &'tcx Expr<'_>) -> boo
475475
match constant(cx, cx.tables, expr) {
476476
Some((Constant::F32(f), _)) => f == 0.0 || f.is_infinite(),
477477
Some((Constant::F64(f), _)) => f == 0.0 || f.is_infinite(),
478+
Some((Constant::Vec(vec), _)) => vec.iter().all(|f| match f {
479+
Constant::F32(f) => *f == 0.0 || (*f).is_infinite(),
480+
Constant::F64(f) => *f == 0.0 || (*f).is_infinite(),
481+
_ => false,
482+
}),
478483
_ => false,
479484
}
480485
}

0 commit comments

Comments
 (0)