mirror of
https://github.com/allankoechke/rust.git
synced 2026-11-30 11:05:36 +00:00
Lint against iterator functions that panic when `N` is zero This PR extends the deny-by-default `unconditional_panic` lint, by linting on iterator functions that panics when `N` (chunks/windows size) is zero[^attr]. Those methods are [documented](https://doc.rust-lang.org/std/primitive.slice.html#panics-11) to panic if `N` is zero. ``` error: this operation will panic at runtime --> $DIR/const-n-is-zero.rs:11:13 | LL | let _ = s.array_windows::<0>(); | ^^^^^^^^^^^^^^^^^^^^^^ const parameter `N` is zero | = note: `#[deny(unconditional_panic)]` on by default ``` cc @rust-lang/libs-api [^attr]: this is done by introducing a new internal attribute on the const parameter: `#[rustc_panics_when_zero]`